Browse Source

no message

xingzai 1 year ago
parent
commit
4f46ccbd7a
4 changed files with 87 additions and 0 deletions
  1. 66 0
      controllers/micro_roadshow.go
  2. 7 0
      models/activity_help_ask.go
  3. 9 0
      routers/commentsRouter.go
  4. 5 0
      routers/router.go

+ 66 - 0
controllers/micro_roadshow.go

@@ -0,0 +1,66 @@
+package controllers
+
+import "hongze/hongze_mfyx/models"
+
+// 微路演 (查看留言详情,之前老的项目写到这个模块下了)
+type MicroRoadShowController struct {
+	BaseAuthController
+}
+
+// @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
+}

+ 7 - 0
models/activity_help_ask.go

@@ -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
+}

+ 9 - 0
routers/commentsRouter.go

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

+ 5 - 0
routers/router.go

@@ -113,6 +113,11 @@ func init() {
 				&controllers.AdviceController{},
 			),
 		),
+		web.NSNamespace("/micro_roadshow",
+			web.NSInclude(
+				&controllers.MicroRoadShowController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }