score.go 988 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package ferroalloy
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. "mtp2_if/models"
  7. "net/http"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // Signin
  11. // @Summary 用户签到
  12. // @Produce json
  13. // @Security ApiKeyAuth
  14. // @Param jsonBody body models.THJSigninReq true "用户签到请求"
  15. // @Success 200 {object} models.THJSigninRsp
  16. // @Failure 500 {object} app.Response
  17. // @Router /Ferroalloy/Signin [post]
  18. // @Tags 铁合金
  19. func Signin(c *gin.Context) {
  20. a := app.GinUtils{Gin: app.Gin{C: c}}
  21. m := models.THJSigninReq{}
  22. a.DoBindReq(&m)
  23. // 判断Token与UserID是否对应
  24. userID, exists := c.Get("requserid")
  25. if !exists || userID != m.USERID {
  26. a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  27. return
  28. }
  29. if rsp, err := m.Signin(); err == nil {
  30. a.Response(http.StatusOK, e.SUCCESS, rsp)
  31. } else {
  32. logger.GetLogger().Errorf("insert fail, %v", err)
  33. a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  34. }
  35. }