feat(smoke): support reason tags on smoke logs
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"wx_service/internal/middleware"
|
||||
"wx_service/internal/model"
|
||||
quitcheckinservice "wx_service/internal/quitcheckin/service"
|
||||
smokemodel "wx_service/internal/smoke/model"
|
||||
smokeservice "wx_service/internal/smoke/service"
|
||||
)
|
||||
|
||||
@@ -58,10 +59,11 @@ type createSmokeLogRequest struct {
|
||||
// 只记录“日期”即可;如果不传,后端会按当天处理
|
||||
SmokeTime string `json:"smoke_time"`
|
||||
// 真实抽烟时间(精确到时分秒,可补录)
|
||||
SmokeAt string `json:"smoke_at"`
|
||||
Remark string `json:"remark"`
|
||||
Level *int64 `json:"level"`
|
||||
Num *int `json:"num"`
|
||||
SmokeAt string `json:"smoke_at"`
|
||||
Remark string `json:"remark"`
|
||||
ReasonTags smokemodel.StringSlice `json:"reason_tags"`
|
||||
Level *int64 `json:"level"`
|
||||
Num *int `json:"num"`
|
||||
}
|
||||
|
||||
func (h *SmokeHandler) Create(c *gin.Context) {
|
||||
@@ -120,11 +122,12 @@ func (h *SmokeHandler) Create(c *gin.Context) {
|
||||
}
|
||||
|
||||
record, err := h.smokeLogService.Create(c.Request.Context(), int(user.ID), smokeservice.CreateSmokeLogRequest{
|
||||
SmokeTime: smokeTime,
|
||||
SmokeAt: smokeAt,
|
||||
Remark: req.Remark,
|
||||
Level: level,
|
||||
Num: num,
|
||||
SmokeTime: smokeTime,
|
||||
SmokeAt: smokeAt,
|
||||
Remark: req.Remark,
|
||||
ReasonTags: req.ReasonTags,
|
||||
Level: level,
|
||||
Num: num,
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, model.Error(http.StatusInternalServerError, "创建记录失败,请稍后重试"))
|
||||
@@ -135,9 +138,10 @@ func (h *SmokeHandler) Create(c *gin.Context) {
|
||||
}
|
||||
|
||||
type resistedSmokeLogRequest struct {
|
||||
SmokeTime string `json:"smoke_time"`
|
||||
SmokeAt string `json:"smoke_at"`
|
||||
Remark string `json:"remark"`
|
||||
SmokeTime string `json:"smoke_time"`
|
||||
SmokeAt string `json:"smoke_at"`
|
||||
Remark string `json:"remark"`
|
||||
ReasonTags smokemodel.StringSlice `json:"reason_tags"`
|
||||
}
|
||||
|
||||
// Resist 表示“想抽但忍住了”:在 fa_smoke_log 中写入 level=0,num=0。
|
||||
@@ -171,11 +175,12 @@ func (h *SmokeHandler) Resist(c *gin.Context) {
|
||||
}
|
||||
|
||||
record, err := h.smokeLogService.Create(c.Request.Context(), int(user.ID), smokeservice.CreateSmokeLogRequest{
|
||||
SmokeTime: smokeTime,
|
||||
SmokeAt: smokeAt,
|
||||
Remark: req.Remark,
|
||||
Level: 0,
|
||||
Num: 0,
|
||||
SmokeTime: smokeTime,
|
||||
SmokeAt: smokeAt,
|
||||
Remark: req.Remark,
|
||||
ReasonTags: req.ReasonTags,
|
||||
Level: 0,
|
||||
Num: 0,
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, model.Error(http.StatusInternalServerError, "创建记录失败,请稍后重试"))
|
||||
@@ -331,11 +336,12 @@ func (h *SmokeHandler) LatestLogs(c *gin.Context) {
|
||||
}
|
||||
|
||||
type updateSmokeLogRequest struct {
|
||||
SmokeTime *string `json:"smoke_time"`
|
||||
SmokeAt *string `json:"smoke_at"`
|
||||
Remark *string `json:"remark"`
|
||||
Level *int64 `json:"level"`
|
||||
Num *int `json:"num"`
|
||||
SmokeTime *string `json:"smoke_time"`
|
||||
SmokeAt *string `json:"smoke_at"`
|
||||
Remark *string `json:"remark"`
|
||||
ReasonTags *smokemodel.StringSlice `json:"reason_tags"`
|
||||
Level *int64 `json:"level"`
|
||||
Num *int `json:"num"`
|
||||
}
|
||||
|
||||
func (h *SmokeHandler) Update(c *gin.Context) {
|
||||
@@ -402,6 +408,7 @@ func (h *SmokeHandler) Update(c *gin.Context) {
|
||||
SmokeAtProvided: smokeAtProvided,
|
||||
SmokeAt: smokeAt,
|
||||
Remark: req.Remark,
|
||||
ReasonTags: req.ReasonTags,
|
||||
Level: req.Level,
|
||||
Num: req.Num,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user