Browse Source

活动分享页和活动预览页相关接口

庄逸洲 4 years ago
parent
commit
5cf3cac466
1 changed files with 38 additions and 0 deletions
  1. 38 0
      controllers/marketing_tool/activity_controller.go

+ 38 - 0
controllers/marketing_tool/activity_controller.go View File

@@ -20,6 +20,7 @@ func ActivityCtlRegistRouters() {
20 20
 	beego.Router("/api/activity/signups", &ActivityAPIController{}, "get:SignupUsers")
21 21
 	beego.Router("/api/activity/delete", &ActivityAPIController{}, "post:DeleteActivity")
22 22
 	beego.Router("/api/activity/publish", &ActivityAPIController{}, "post:PublishActivity")
23
+	beego.Router("/api/activity/shareinfo", &ActivityAPIController{}, "get:GetActivityShareInfo")
23 24
 }
24 25
 
25 26
 type ActivityAPIController struct {
@@ -157,12 +158,17 @@ func (this *ActivityAPIController) GetActivity() {
157 158
 		paragraphContent = paragraph.Text
158 159
 	}
159 160
 
161
+	currentOrg := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
160 162
 	this.ServeSuccessJSON(map[string]interface{}{
161 163
 		"activity": activity,
162 164
 		"paragraph": map[string]interface{}{
163 165
 			"title":   paragraphTitle,
164 166
 			"content": paragraphContent,
165 167
 		},
168
+		"org": map[string]interface{}{
169
+			"logo": currentOrg.OrgLogo,
170
+			"name": currentOrg.OrgName,
171
+		},
166 172
 	})
167 173
 }
168 174
 
@@ -479,3 +485,35 @@ func (this *ActivityAPIController) PublishActivity() {
479 485
 	}
480 486
 	this.ServeSuccessJSON(nil)
481 487
 }
488
+
489
+// /api/activity/shareinfo [get]
490
+// @param id:int
491
+func (this *ActivityAPIController) GetActivityShareInfo() {
492
+	activityID, _ := this.GetInt64("id")
493
+	if activityID <= 0 {
494
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
495
+		return
496
+	}
497
+
498
+	adminUserInfo := this.GetAdminUserInfo()
499
+	activity, getActivityErr := marketing_tool_service.GetActivityWithID(adminUserInfo.CurrentOrgId, activityID)
500
+	if getActivityErr != nil {
501
+		this.ErrorLog("获取活动失败:%v", getActivityErr)
502
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
503
+		return
504
+	} else if activity == nil {
505
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeActivityNotExist)
506
+		return
507
+	}
508
+
509
+	wxShareModel, getWxShareErr := marketing_tool_service.GetActivityWxShareByActivityID(activity.Id)
510
+	if getWxShareErr != nil || wxShareModel == nil {
511
+		this.ErrorLog("获取活动微信分享信息失败:%v", getWxShareErr)
512
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
513
+		return
514
+	}
515
+
516
+	this.ServeSuccessJSON(map[string]interface{}{
517
+		"url": wxShareModel.ShortURL,
518
+	})
519
+}