Browse Source

模版消息留言详情接口

xingzai 1 year ago
parent
commit
25a5786f09
4 changed files with 90 additions and 3 deletions
  1. 58 0
      controllers/micro_roadshow.go
  2. 10 3
      models/activity_help_ask.go
  3. 13 0
      models/article_comment.go
  4. 9 0
      routers/commentsRouter.go

+ 58 - 0
controllers/micro_roadshow.go

@@ -779,3 +779,61 @@ func (this *MicroRoadShowController) Mycollect() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 模版消息留言详情
+// @Description 模版消息留言详情接口
+// @Param   SourceId		query	int		true	"资源ID"
+// @Param   SourceType	query	int		true	"留言类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频"
+// @Success Ret=200 {object} models.CygxArticleCommentWxResp
+// @router /comment/detail [get]
+func (this *MicroRoadShowController) CommentDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	sourceId, _ := this.GetInt("SourceId")
+	sourceType, _ := this.GetInt("SourceType")
+	resp := new(models.CygxArticleCommentWxResp)
+	if sourceType == 1 || sourceType == 3 || sourceType == 4 || sourceType == 5 {
+		detail, err := models.GetArticleCommentById(sourceId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
+			return
+		}
+		resp.Content = detail.Content
+		if sourceType == 1 {
+			resp.SourceId = detail.ArticleId
+			resp.RedirectType = 1
+		} else if sourceType == 3 {
+			resp.SourceId = detail.IndustryId
+			resp.RedirectType = 3
+		} else {
+			resp.SourceId = detail.ActivityId
+			resp.RedirectType = 2
+		}
+	} else {
+		detail, err := models.GetCygxActivityHelpAskById(sourceId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
+			return
+		}
+		resp.Content = detail.Content
+		resp.SourceId = detail.ActivityId
+		resp.RedirectType = 2
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	br.Msg = "操作成功"
+	return
+}

+ 10 - 3
models/activity_help_ask.go

@@ -17,7 +17,7 @@ type CygxActivityHelpAsk struct {
 	Content     string    `description:"内容"`
 }
 
-//添加优化建议
+// 添加优化建议
 func AddActivityHelpAsk(item *CygxActivityHelpAsk) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -43,7 +43,7 @@ type CygxAskListResp struct {
 
 //report_or_activity_id
 
-//主题列表
+// 主题列表
 func GetActivityAskList(userId int) (items []*CygxAskList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -60,7 +60,7 @@ func GetActivityAskList(userId int) (items []*CygxAskList, err error) {
 	return
 }
 
-//列表
+// 列表
 func GetArticleAskList(userId int) (items []*CygxAskList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -76,3 +76,10 @@ func GetArticleAskList(userId int) (items []*CygxAskList, err error) {
 	_, err = o.Raw(sql, userId).QueryRows(&items)
 	return
 }
+
+// 通过ID获取详情
+func GetCygxActivityHelpAskById(id int) (item *CygxActivityHelpAsk, err error) {
+	sql := `SELECT * FROM cygx_activity_help_ask WHERE ask_id=? `
+	err = orm.NewOrm().Raw(sql, id).QueryRow(&item)
+	return
+}

+ 13 - 0
models/article_comment.go

@@ -70,3 +70,16 @@ type CygxArticleCommentResp struct {
 type CygxCommentListResp struct {
 	List []*CygxArticleCommentResp
 }
+
+// 通过ID获取详情
+func GetArticleCommentById(id int) (item *CygxArticleCommentResp, err error) {
+	sql := `SELECT * FROM cygx_article_comment WHERE id=? `
+	err = orm.NewOrm().Raw(sql, id).QueryRow(&item)
+	return
+}
+
+type CygxArticleCommentWxResp struct {
+	Content      string `description:"内容"`
+	SourceId     int    `description:"跳转ID"`
+	RedirectType int    `description:"跳转类型 1文章 2活动 3产业资源包"`
+}

+ 9 - 0
routers/commentsRouter.go

@@ -700,6 +700,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "CommentDetail",
+            Router: `/comment/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "List",