feat: update smoke profile area handling
This commit is contained in:
@@ -18,6 +18,7 @@ type upsertSmokeProfileRequest struct {
|
||||
BaselineCigsPerDay *int `json:"baseline_cigs_per_day"`
|
||||
SmokingYears *float64 `json:"smoking_years"`
|
||||
PackPriceCent *int `json:"pack_price_cent"`
|
||||
Mode *string `json:"mode"`
|
||||
|
||||
SmokeMotivations *[]string `json:"smoke_motivations"`
|
||||
QuitMotivations *[]string `json:"quit_motivations"`
|
||||
@@ -71,6 +72,13 @@ func (h *SmokeHandler) UpsertProfile(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if req.Mode != nil {
|
||||
mode := strings.TrimSpace(*req.Mode)
|
||||
if mode != "" && mode != smokeservice.SmokeModeQuit && mode != smokeservice.SmokeModeRecord {
|
||||
c.JSON(http.StatusBadRequest, model.Error(http.StatusBadRequest, "mode 仅支持 quit 或 record"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
quitDateProvided := false
|
||||
var quitDate *time.Time
|
||||
@@ -91,6 +99,7 @@ func (h *SmokeHandler) UpsertProfile(c *gin.Context) {
|
||||
BaselineCigsPerDay: req.BaselineCigsPerDay,
|
||||
SmokingYears: req.SmokingYears,
|
||||
PackPriceCent: req.PackPriceCent,
|
||||
Mode: req.Mode,
|
||||
SmokeMotivations: req.SmokeMotivations,
|
||||
QuitMotivations: req.QuitMotivations,
|
||||
WakeUpTime: req.WakeUpTime,
|
||||
|
||||
Reference in New Issue
Block a user