score.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. "strconv"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // Signin
  12. // @Summary 用户签到
  13. // @Produce json
  14. // @Security ApiKeyAuth
  15. // @Param jsonBody body models.THJSigninReq true "用户签到请求"
  16. // @Success 200 {object} models.THJSigninRsp
  17. // @Failure 500 {object} app.Response
  18. // @Router /Ferroalloy/Signin [post]
  19. // @Tags 铁合金
  20. func Signin(c *gin.Context) {
  21. a := app.GinUtils{Gin: app.Gin{C: c}}
  22. m := models.THJSigninReq{}
  23. a.DoBindReq(&m)
  24. // 判断Token与UserID是否对应
  25. userID, exists := c.Get("requserid")
  26. if !exists || userID != strconv.Itoa(int(m.USERID)) {
  27. a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  28. return
  29. }
  30. if rsp, err := m.Signin(); err == nil {
  31. a.Response(http.StatusOK, e.SUCCESS, rsp)
  32. } else {
  33. logger.GetLogger().Errorf("insert fail, %v", err)
  34. a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  35. }
  36. }
  37. // QueryUserScoreLog
  38. // @Summary 查询我的积分流水
  39. // @Produce json
  40. // @Security ApiKeyAuth
  41. // @Param userid query int true "用户ID"
  42. // @Param page query int false "页码"
  43. // @Param pagesize query int false "每页条数"
  44. // @Success 200 {array} models.GThjuserscorelog
  45. // @Failure 500 {object} app.Response
  46. // @Router /Ferroalloy/QueryUserScoreLog [get]
  47. // @Tags 铁合金
  48. func QueryUserScoreLog(c *gin.Context) {
  49. a := app.GinUtils{Gin: app.Gin{C: c}}
  50. m := models.GThjuserscorelog{}
  51. a.DoBindReq(&m)
  52. a.DoGetDataByPage(&m)
  53. }