score.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 stype query string false "[格式:1,2,3] 配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置"
  43. // @Param page query int false "页码"
  44. // @Param pagesize query int false "每页条数"
  45. // @Success 200 {array} models.GThjuserscorelog
  46. // @Failure 500 {object} app.Response
  47. // @Router /Ferroalloy/QueryUserScoreLog [get]
  48. // @Tags 铁合金
  49. func QueryUserScoreLog(c *gin.Context) {
  50. a := app.GinUtils{Gin: app.Gin{C: c}}
  51. m := models.GThjuserscorelog{}
  52. a.DoBindReq(&m)
  53. a.DoGetDataByPage(&m)
  54. }
  55. // QueryTHJScoreConfig
  56. // @Summary 查询积分配置
  57. // @Produce json
  58. // @Security ApiKeyAuth
  59. // @Param stype query string false "[格式:1,2,3] 配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置"
  60. // @Success 200 {array} models.Thjscoreconfig
  61. // @Failure 500 {object} app.Response
  62. // @Router /Ferroalloy/QueryTHJScoreConfig [get]
  63. // @Tags 铁合金
  64. func QueryTHJScoreConfig(c *gin.Context) {
  65. a := app.GinUtils{Gin: app.Gin{C: c}}
  66. m := models.ThjscoreconfigReq{}
  67. if err := a.C.ShouldBind(&m); err != nil {
  68. a.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  69. return
  70. }
  71. if rsp, err := m.Get(); err == nil {
  72. a.Gin.Response(http.StatusOK, e.SUCCESS, rsp)
  73. } else {
  74. logger.GetLogger().Errorf("query fail, %v", err)
  75. a.Gin.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  76. }
  77. }