Selaa lähdekoodia

我的留言筛选

ziwen 2 vuotta sitten
vanhempi
commit
8c3d26eb32
2 muutettua tiedostoa jossa 18 lisäystä ja 4 poistoa
  1. 4 1
      controllers/user.go
  2. 14 3
      models/article_comment.go

+ 4 - 1
controllers/user.go

@@ -1532,6 +1532,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() {
@@ -1547,8 +1548,10 @@ func (this *UserController) CommnetList() {
 		br.Ret = 408
 		return
 	}
+	commentType, _ := this.GetInt("CommentType")
+
 	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
 }