123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- package eta_trial
- import (
- "encoding/json"
- "eta/eta_api/controllers"
- "eta/eta_api/models"
- "eta/eta_api/models/eta_trial"
- etaTrialService "eta/eta_api/services/eta_trial"
- "eta/eta_api/utils"
- )
- // EtaTrialController ETA试用
- type EtaTrialController struct {
- controllers.BaseAuthController
- }
- // UpdateActiveTime
- // @Title 累计活跃时长
- // @Description 累计活跃时长
- // @Param ActiveTime query int true "活跃时长"
- // @Param Part query string true "活跃板块"
- // @Success 200 {object} models.ETATrialAddReq
- // @router /user/active [post]
- func (this *EtaTrialController) UpdateActiveTime() {
- br := new(models.BaseResponse).Init()
- defer func() {
- if br.ErrMsg == "" {
- br.IsSendEmail = false
- }
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- // 仅试用平台用
- if utils.BusinessCode != utils.BusinessCodeSandbox {
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- var req eta_trial.UpdateUserActiveTimeReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Part == "" {
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- params := etaTrialService.UpdateEtaTrialUserActiveTimeReq{
- UserName: sysUser.RealName,
- Mobile: sysUser.Mobile,
- ActiveTime: req.ActiveTime,
- Part: req.Part,
- }
- res, e := etaTrialService.UpdateEtaTrialUserActiveTime(params)
- if e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "更新ETA试用用户活跃时长失败, Err: " + e.Error()
- return
- }
- if !res {
- br.Msg = "操作失败"
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "新增成功"
- }
- // UpdateLoginDuration
- // @Title 更新用户登录时长
- // @Description 更新用户登录时长
- // @Param ActiveTime query int true "活跃时长"
- // @Success 200 {object} models.ETATrialAddReq
- // @router /user/login_duration [post]
- func (this *EtaTrialController) UpdateLoginDuration() {
- br := new(models.BaseResponse).Init()
- defer func() {
- if br.ErrMsg == "" {
- br.IsSendEmail = false
- }
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- // 仅试用平台用
- if utils.BusinessCode != utils.BusinessCodeSandbox {
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- var req eta_trial.UpdateUserLoginDurationReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- params := etaTrialService.UpdateEtaTrialUserLoginDurationReq{
- UserName: sysUser.RealName,
- Mobile: sysUser.Mobile,
- ActiveTime: req.ActiveTime,
- }
- res, e := etaTrialService.UpdateEtaTrialUserLoginDuration(params)
- if e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "更新ETA试用用户登录时长失败, Err: " + e.Error()
- return
- }
- if !res {
- br.Msg = "操作失败"
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "新增成功"
- }
|