Prechádzať zdrojové kódy

Merge branch 'cygx_8.7' into debug

ziwen 2 rokov pred
rodič
commit
4ab38ef776
2 zmenil súbory, kde vykonal 18 pridanie a 4 odobranie
  1. 4 1
      controllers/user.go
  2. 14 3
      models/article_comment.go

+ 4 - 1
controllers/user.go

@@ -1546,6 +1546,7 @@ func (this *UserCommonController) LoginPublic() {
 
 // @Title 获取我的留言
 // @Description 获取我的留言列表
+// @Param   CommentType		query	int		true	"留言种类,1报告 2微路演"
 // @Success 200 {object} models.CygxCommentListResp
 // @router /comment/list [get]
 func (this *UserController) CommnetList() {
@@ -1561,8 +1562,10 @@ func (this *UserController) CommnetList() {
 		br.Ret = 408
 		return
 	}
+	commentType, _ := this.GetInt("CommentType", 1)
+
 	userId := this.User.UserId
-	commentlist, err := models.GetCommentList(userId)
+	commentlist, err := models.GetCommentList(userId, commentType)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()

+ 14 - 3
models/article_comment.go

@@ -33,14 +33,25 @@ type AddCygxArticleCommentReq struct {
 }
 
 //我的留言列表
-func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
+func GetCommentList(userId, commentType int) (items []*CygxArticleComment, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT
+	sql := ""
+	if commentType == 1{
+		sql = `SELECT
 			* 
 		FROM
 			cygx_article_comment AS c
 		WHERE
-			user_id = ? ORDER BY c.create_time DESC`
+			user_id = ? AND article_id <> 0 ORDER BY c.create_time DESC`
+	} else if commentType == 2{
+		sql = `SELECT
+			* 
+		FROM
+			cygx_article_comment AS c
+		WHERE
+			user_id = ? AND article_id = 0 ORDER BY c.create_time DESC`
+	}
+
 	_, err = o.Raw(sql, userId).QueryRows(&items)
 	return
 }