| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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)
- }
- }
- // QueryUserScoreLog
- // @Summary 查询我的积分流水
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户ID"
- // @Param stype query string false "[格式:1,2,3] 配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置"
- // @Param page query int false "页码"
- // @Param pagesize query int false "每页条数"
- // @Success 200 {array} models.GThjuserscorelog
- // @Failure 500 {object} app.Response
- // @Router /Ferroalloy/QueryUserScoreLog [get]
- // @Tags 铁合金
- func QueryUserScoreLog(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- m := models.GThjuserscorelog{}
- a.DoBindReq(&m)
- a.DoGetDataByPage(&m)
- }
- // QueryTHJScoreConfig
- // @Summary 查询积分配置
- // @Produce json
- // @Security ApiKeyAuth
- // @Param stype query string false "[格式:1,2,3] 配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置"
- // @Success 200 {array} models.Thjscoreconfig
- // @Failure 500 {object} app.Response
- // @Router /Ferroalloy/QueryTHJScoreConfig [get]
- // @Tags 铁合金
- func QueryTHJScoreConfig(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- m := models.ThjscoreconfigReq{}
- if err := a.C.ShouldBind(&m); err != nil {
- a.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if rsp, err := m.Get(); err == nil {
- a.Gin.Response(http.StatusOK, e.SUCCESS, rsp)
- } else {
- logger.GetLogger().Errorf("query fail, %v", err)
- a.Gin.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- }
- }
|