瀏覽代碼

Merge branch 'cygx_8.7' into debug

# Conflicts:
#	controllers/report.go
#	models/db.go
ziwen 2 年之前
父節點
當前提交
5c20e57b01
共有 5 個文件被更改,包括 99 次插入1 次删除
  1. 33 0
      controllers/user.go
  2. 21 1
      models/article_comment.go
  3. 1 0
      models/db.go
  4. 9 0
      routers/commentsRouter.go
  5. 35 0
      services/wx_template_msg.go

+ 33 - 0
controllers/user.go

@@ -1543,3 +1543,36 @@ func (this *UserCommonController) LoginPublic() {
 	br.Data = resp
 	br.Msg = "登录成功"
 }
+
+// @Title 获取我的留言
+// @Description 获取我的留言列表
+// @Success 200 {object} models.CygxCommentListResp
+// @router /comment/list [get]
+func (this *UserController) CommnetList() {
+	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
+	}
+	userId := this.User.UserId
+	commentlist, err := models.GetCommentList(userId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.CygxCommentListResp)
+	resp.List = commentlist
+	br.Msg = "获取成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 21 - 1
models/article_comment.go

@@ -8,13 +8,16 @@ import (
 type CygxArticleComment struct {
 	Id       int       `orm:"column(id);pk" description:"留言id"`
 	UserId      int       `description:"用户id"`
-	ArticleId  int       `description:"活动id"`
+	ArticleId  int       `description:"文章id"`
+	ActivityId  int       `description:"活动id"`
+	VideoId  int       `description:"视频id"`
 	CreateTime  time.Time `description:"创建时间"`
 	Mobile      string    `description:"手机号"`
 	Email       string    `description:"邮箱"`
 	CompanyId   int       `description:"公司id"`
 	CompanyName string    `description:"公司名称"`
 	Content     string    `description:"内容"`
+	Title     string    `description:"标题"`
 }
 
 
@@ -30,3 +33,20 @@ type AddCygxArticleCommentReq struct {
 	ArticleId int    `description:"文章id"`
 	Content    string `description:"内容"`
 }
+
+//我的留言列表
+func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			* 
+		FROM
+			cygx_article_comment AS c
+		WHERE
+			user_id = ? ORDER BY c.create_time DESC`
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+type CygxCommentListResp struct {
+	List []*CygxArticleComment
+}

+ 1 - 0
models/db.go

@@ -128,6 +128,7 @@ func init() {
 		new(CygxActivitySpecialTrip),
 		new(CygxArticleComment),
 		new(CygxArticleData),
+		new(CygxArticleComment),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 9 - 0
routers/commentsRouter.go

@@ -1141,6 +1141,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "CommnetList",
+            Router: `/comment/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "AddCountryCcode",

+ 35 - 0
services/wx_template_msg.go

@@ -658,3 +658,38 @@ func SendActivityOnenIdWxTemplateMsg(first, keyWord1, keyWord2, keyWord3, keyWor
 	WxSendTemplateMsg(sendUrl, sendMap, openIdList, "", utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
 	return
 }
+
+//发送用户留言提醒
+func SendCommentWxTemplateMsg(keyWord1, keyWord2 string, openIdList []*models.OpenIdList, articleId int) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint("发送用户用户留言提醒,文章ID:", articleId), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+	accessToken, err := models.GetWxAccessTokenByXzs()
+	if err != nil {
+		msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if accessToken == "" {
+		msg = "accessToken is empty"
+		return
+	}
+	var first string
+	first = keyWord1
+	keyword1 := keyWord2
+	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
+	templateId := utils.WxMsgTemplateIdArticleUserRemind
+	sendMap := make(map[string]interface{})
+	sendData := make(map[string]interface{})
+	sendMap["template_id"] = templateId
+	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "activityPages/specialDetail/specialDetail?id=" + strconv.Itoa(articleId)}
+	sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
+	sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
+	sendMap["data"] = sendData
+	WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
+	return
+}