Переглянути джерело

调整问答状态枚举值

hsun 2 роки тому
батько
коміт
a363d077e5
2 змінених файлів з 13 додано та 9 видалено
  1. 3 3
      models/response/community.go
  2. 10 6
      services/community/question.go

+ 3 - 3
models/response/community.go

@@ -31,7 +31,7 @@ type CommunityQuestionAudioItem struct {
 }
 
 type CommunityReplyTotal struct {
-	Wait   int `json:"wait"`
-	Repied int `json:"repied"`
-	Total  int `json:"total"`
+	Wait    int `json:"wait"`
+	Replied int `json:"replied"`
+	Total   int `json:"total"`
 }

+ 10 - 6
services/community/question.go

@@ -163,6 +163,7 @@ func CreateQuestion(userId int, mobile, realName, content string) (err error) {
 		Mobile:          mobile,
 		RealName:        realName,
 		QuestionContent: content,
+		ReplyStatus:     1,
 	}
 	if e := item.Create(); e != nil {
 		err = errors.New("新增问题失败 Err:" + e.Error())
@@ -176,7 +177,7 @@ func ReplyUserQuestion(replierId, questionId int, audios []*request.ReplyReqAudi
 		err = errors.New("获取提问信息失败 Err:" + e.Error())
 		return
 	}
-	if item.ReplyStatus < 1 {
+	if item.ReplyStatus < 2 {
 		err = errors.New("回复状态有误")
 		return
 	}
@@ -188,7 +189,7 @@ func ReplyUserQuestion(replierId, questionId int, audios []*request.ReplyReqAudi
 	updateCols := make([]string, 0)
 	updateCols = append(updateCols, "reply_status", "reply_time", "modify_time")
 	nowTime := time.Now().Local()
-	item.ReplyStatus = 2
+	item.ReplyStatus = 3
 	item.ReplyTime = nowTime
 	item.ModifyTime = nowTime
 	// 音频
@@ -205,7 +206,9 @@ func ReplyUserQuestion(replierId, questionId int, audios []*request.ReplyReqAudi
 	}
 	if e := yb_community_question.UpdateQuestionAndAudioList(item, updateCols, audioList); e != nil {
 		err = errors.New("UpdateQuestionAndAudioList Err:" + e.Error())
+		return
 	}
+	// TODO:推送回复模板消息给提问人
 	return
 }
 
@@ -238,13 +241,14 @@ func GetReplyListTotal(replierUserId int) (resp *response.CommunityReplyTotal, e
 	}
 	resp = new(response.CommunityReplyTotal)
 	for _, v := range countList {
-		if v.ReplyStatus == 1 {
+		if v.ReplyStatus == 2 {
 			resp.Wait = v.Total
+			continue
 		}
-		if v.ReplyStatus == 2 {
-			resp.Repied = v.Total
+		if v.ReplyStatus == 3 {
+			resp.Replied = v.Total
 		}
 	}
-	resp.Total = resp.Wait + resp.Repied
+	resp.Total = resp.Wait + resp.Replied
 	return
 }