Browse Source

Merge branch 'cygx/cygx_12.2' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

xingzai 1 year ago
parent
commit
976a595fef
3 changed files with 84 additions and 0 deletions
  1. 65 0
      controllers/cygx/activity.go
  2. 10 0
      models/cygx/activity.go
  3. 9 0
      routers/commentsRouter.go

+ 65 - 0
controllers/cygx/activity.go

@@ -1637,3 +1637,68 @@ func (this *ActivityCoAntroller) ImgToText() {
 	br.Data = resp
 	br.IsAddLog = true
 }
+
+// @Title 活动的置顶与取消置顶
+// @Description 活动的发布与取消发布接口
+// @Param	request	body cygx.ActivityIdRep true "type json string"
+// @Success 200 操作成功
+// @router /activity/tope_change [post]
+func (this *ActivityCoAntroller) TopeChange() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req cygx.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := cygx.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	//校验活动后台管理员、销售是否有修改权限
+	havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
+	if err != nil {
+		br.Msg = "获取管理员身份信息失败"
+		br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
+		return
+	}
+	if !havePower {
+		br.Msg = popupMsg
+		return
+	}
+	var topTime int
+	//如果有置顶时间就设为取消置顶,如果没有就写入当前置顶时间
+	if activityInfo.TopTime == 0 {
+		topTime = int(time.Now().Unix())
+	}
+	err = cygx.UpdateActivityTopTime(activityId, topTime)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	br.IsAddLog = true //添加操作日志记录
+}

+ 10 - 0
models/cygx/activity.go

@@ -170,6 +170,7 @@ type ActivityDetail struct {
 	ChartPermissionNameDeputy string                    `description:"副行业名称"`
 	BackgroundImg             string                    `description:"封面图片"`
 	ShareImg                  string                    `description:"分享图片"`
+	TopTime                   int                       `description:"置顶时间"`
 }
 
 type ActivityDetailRep struct {
@@ -567,6 +568,7 @@ type CygxActivityList struct {
 	IsShowSigninButton        bool   `description:"是否展示签到码按钮"`
 	SigninImg                 string `description:"签到码图片"`
 	ChartPermissionNameDeputy string `description:"副行业名称"`
+	TopTime                   int    `description:"置顶时间"`
 }
 
 type GetCygxActivityListRep struct {
@@ -704,3 +706,11 @@ type AliyunOcrTextActivityResp struct {
 type AliyunOcrTextActivityListResp struct {
 	List []*AliyunOcrTextActivityResp
 }
+
+// 更新活动置顶时间
+func UpdateActivityTopTime(activityId, topTime int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` UPDATE cygx_activity SET  top_time=? WHERE activity_id=?`
+	_, err = o.Raw(sql, topTime, activityId).Exec()
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -565,6 +565,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "TopeChange",
+            Router: `/activity/tope_change`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityLossCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityLossCoAntroller"],
         beego.ControllerComments{
             Method: "CompanyList",