xingzai 7 ヶ月 前
コミット
6d5e052224

+ 10 - 11
controllers/yanxuan_special_message.go

@@ -314,20 +314,19 @@ func (this *YanxuanSpecialMessageController) MessageTop() {
 		br.ErrMsg = "操作失败,Err:" + err.Error()
 	}
 	yanxuanSpecialId := messagerDetail.YanxuanSpecialId
-
-	countTop, err := models.GetCygxYanxuanSpecialMessagerCountTop(yanxuanSpecialId)
-	if err != nil {
-		br.Msg = "操作失败!"
-		br.ErrMsg = "操作失败,Err:" + err.Error()
-		return
-	}
-	if countTop > 0 {
-		br.Msg = "此文章已有置顶留言"
-		return
-	}
 	var topTime int
 	var msgContent string
 	if doType == 1 {
+		countTop, err := models.GetCygxYanxuanSpecialMessagerCountTop(yanxuanSpecialId)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		if countTop > 0 {
+			br.Msg = "此文章已有置顶留言"
+			return
+		}
 		topTime = int(time.Now().Unix())
 		msgContent = "已置顶"
 	} else {

+ 1 - 1
models/cygx_yanxuan_special_message.go

@@ -79,7 +79,7 @@ func UpdateCygxYanxuanSpecialMessageTopTime(topTime, messageId int) (err error)
 func UpdateCygxYanxuanSpecialMessageStatus(status int, publicTime string, messageIds []int) (err error) {
 	o := orm.NewOrm()
 	sql := ``
-	sql = `UPDATE cygx_yanxuan_special_message SET  top_time = 0 status = ?  ,public_time = ?  WHERE message_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `)  OR  parent_id   IN (` + utils.GetOrmInReplace(len(messageIds)) + `) `
+	sql = `UPDATE cygx_yanxuan_special_message SET  top_time = 0 , status = ?  ,public_time = ?  WHERE message_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `)  OR  parent_id   IN (` + utils.GetOrmInReplace(len(messageIds)) + `) `
 	_, err = o.Raw(sql, status, publicTime, messageIds, messageIds).Exec()
 	return
 }