package ferroalloy import ( "mtp2_if/global/app" "mtp2_if/global/e" "mtp2_if/logger" "mtp2_if/models" "net/http" "strconv" "github.com/gin-gonic/gin" ) // Signin // @Summary 用户签到 // @Produce json // @Security ApiKeyAuth // @Param jsonBody body models.THJSigninReq true "用户签到请求" // @Success 200 {object} models.THJSigninRsp // @Failure 500 {object} app.Response // @Router /Ferroalloy/Signin [post] // @Tags 铁合金 func Signin(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} m := models.THJSigninReq{} a.DoBindReq(&m) // 判断Token与UserID是否对应 userID, exists := c.Get("requserid") if !exists || userID != strconv.Itoa(int(m.USERID)) { a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil) return } if rsp, err := m.Signin(); err == nil { a.Response(http.StatusOK, e.SUCCESS, rsp) } else { logger.GetLogger().Errorf("insert fail, %v", err) a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil) } }