Parcourir la source

fix: 问答社区新原型改动

hsun il y a 2 ans
Parent
commit
5527dbda92

+ 25 - 18
controller/community/question.go

@@ -24,7 +24,6 @@ import (
 // @Param only_mine				query int false "只看我的"
 // @Param chart_permission_id	query int false "品种权限ID"
 // @Param reply_status			query int false "回复状态 0-全部 2-待回答 3-已回答"
-// @Param replier_user_id		query int false "回复人ID"
 // @Success 200 {object} []respond.CommunityQuestionItem
 // @failure 400 {string} string "获取失败"
 // @Router /question/list [get]
@@ -41,7 +40,7 @@ func QuestionList(c *gin.Context) {
 		req.PageSize = utils.PageSize20
 	}
 	userinfo := user.GetInfoByClaims(c)
-	list, err := community.GetQuestionList(req.PageIndex, req.PageSize, req.OnlyMine, req.ChartPermissionId, req.ReplyStatus, req.ReplierUserId, userinfo)
+	list, err := community.GetQuestionList(req.PageIndex, req.PageSize, req.OnlyMine, req.ChartPermissionId, req.ReplyStatus, userinfo)
 	if err != nil {
 		response.FailMsg("获取失败", "QuestionList ErrMsg:"+err.Error(), c)
 		return
@@ -149,31 +148,22 @@ func QuestionReplyRead(c *gin.Context) {
 		return
 	}
 	userinfo := user.GetInfoByClaims(c)
-	if err := community.ReadQuestionReply(int(userinfo.UserID), req.QuestionId); err != nil {
+	if err := community.ReadQuestionReply(req.QuestionId, userinfo); err != nil {
 		response.FailMsg("操作失败", "QuestionReplyRead ErrMsg:"+err.Error(), c)
 		return
 	}
 	response.Ok("操作成功", c)
 }
 
-// QuestionReplyTotal 问答列表数量统计
+// QuestionListTotal 问答列表数量统计
 // @Tags 问答社区模块
 // @Description 问答列表数量统计
-// @Param replier_user_id  query  int  true  "回复人ID"
-// @Success 200 {object} respond.CommunityReplyTotal
+// @Success 200 {object} respond.CommunityQuestionListTotal
 // @failure 400 {string} string "获取失败"
-// @Router /question/reply/total [get]
-func QuestionReplyTotal(c *gin.Context) {
-	var req request.ReplyListTotalReq
-	if err := c.ShouldBind(&req); err != nil {
-		response.Fail("参数有误", c)
-		return
-	}
-	if req.ReplierUserId == 0 {
-		response.Fail("参数有误", c)
-		return
-	}
-	resp, err := community.GetReplyListTotal(req.ReplierUserId)
+// @Router /question/list/total [get]
+func QuestionListTotal(c *gin.Context) {
+	userinfo := user.GetInfoByClaims(c)
+	resp, err := community.GetQuestionListTotal(userinfo)
 	if err != nil {
 		response.FailMsg("获取失败", "QuestionReplyTotal ErrMsg:"+err.Error(), c)
 		return
@@ -248,3 +238,20 @@ func QuestionUploadAudio(c *gin.Context) {
 	}
 	response.OkData("上传成功", resp, c)
 }
+
+// QuestionUnread 我的问答未读数
+// @Tags 问答社区模块
+// @Description 我的问答未读数
+// @Success 200 {int} int "获取成功"
+// @failure 400 {string} string "获取失败"
+// @Router /question/unread [get]
+func QuestionUnread(c *gin.Context) {
+	userinfo := user.GetInfoByClaims(c)
+	total, err := community.GetMyQuestionUnread(userinfo)
+	if err != nil {
+		fmt.Println(err.Error())
+		response.FailMsg("获取失败", "QuestionUnread ErrMsg:"+err.Error(), c)
+		return
+	}
+	response.OkData("获取成功", total, c)
+}

+ 39 - 31
docs/docs.go

@@ -1233,6 +1233,28 @@ var doc = `{
                 }
             }
         },
+        "/question/list/total": {
+            "get": {
+                "description": "问答列表数量统计",
+                "tags": [
+                    "问答社区模块"
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/response.CommunityQuestionListTotal"
+                        }
+                    },
+                    "400": {
+                        "description": "获取失败",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/question/reply": {
             "post": {
                 "description": "发布回复",
@@ -1302,30 +1324,30 @@ var doc = `{
                 }
             }
         },
-        "/question/reply/total": {
-            "get": {
-                "description": "问答列表数量统计",
+        "/question/reply/upload_audio": {
+            "post": {
+                "description": "上传回复音频",
                 "tags": [
                     "问答社区模块"
                 ],
                 "parameters": [
                     {
-                        "type": "integer",
-                        "description": "回复人ID",
-                        "name": "replier_user_id",
+                        "type": "string",
+                        "description": "音频文件",
+                        "name": "file",
                         "in": "query",
                         "required": true
                     }
                 ],
                 "responses": {
                     "200": {
-                        "description": "OK",
+                        "description": "上传成功",
                         "schema": {
-                            "$ref": "#/definitions/response.CommunityReplyTotal"
+                            "type": "string"
                         }
                     },
                     "400": {
-                        "description": "获取失败",
+                        "description": "上传失败",
                         "schema": {
                             "type": "string"
                         }
@@ -1333,30 +1355,21 @@ var doc = `{
                 }
             }
         },
-        "/question/reply/upload_audio": {
-            "post": {
-                "description": "上传回复音频",
+        "/question/unread": {
+            "get": {
+                "description": "我的问答未读数",
                 "tags": [
                     "问答社区模块"
                 ],
-                "parameters": [
-                    {
-                        "type": "string",
-                        "description": "音频文件",
-                        "name": "file",
-                        "in": "query",
-                        "required": true
-                    }
-                ],
                 "responses": {
                     "200": {
-                        "description": "上传成功",
+                        "description": "获取成功",
                         "schema": {
-                            "type": "string"
+                            "type": "int"
                         }
                     },
                     "400": {
-                        "description": "上传失败",
+                        "description": "获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -2343,10 +2356,8 @@ var doc = `{
                 "classifyName": {
                     "type": "string"
                 },
-                "hasPermission": {
-                    "type": "boolean"
-                },
                 "items": {
+                    "description": "HasPermission bool              ` + "`" + `description:\"是否有权限\"` + "`" + `",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/company.PermissionItem"
@@ -2357,9 +2368,6 @@ var doc = `{
         "company.PermissionItem": {
             "type": "object",
             "properties": {
-                "hasPermission": {
-                    "type": "boolean"
-                },
                 "permissionId": {
                     "type": "integer"
                 },
@@ -2622,7 +2630,7 @@ var doc = `{
                 }
             }
         },
-        "response.CommunityReplyTotal": {
+        "response.CommunityQuestionListTotal": {
             "type": "object",
             "properties": {
                 "replied": {

+ 39 - 31
docs/swagger.json

@@ -1219,6 +1219,28 @@
                 }
             }
         },
+        "/question/list/total": {
+            "get": {
+                "description": "问答列表数量统计",
+                "tags": [
+                    "问答社区模块"
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/response.CommunityQuestionListTotal"
+                        }
+                    },
+                    "400": {
+                        "description": "获取失败",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
+        },
         "/question/reply": {
             "post": {
                 "description": "发布回复",
@@ -1288,30 +1310,30 @@
                 }
             }
         },
-        "/question/reply/total": {
-            "get": {
-                "description": "问答列表数量统计",
+        "/question/reply/upload_audio": {
+            "post": {
+                "description": "上传回复音频",
                 "tags": [
                     "问答社区模块"
                 ],
                 "parameters": [
                     {
-                        "type": "integer",
-                        "description": "回复人ID",
-                        "name": "replier_user_id",
+                        "type": "string",
+                        "description": "音频文件",
+                        "name": "file",
                         "in": "query",
                         "required": true
                     }
                 ],
                 "responses": {
                     "200": {
-                        "description": "OK",
+                        "description": "上传成功",
                         "schema": {
-                            "$ref": "#/definitions/response.CommunityReplyTotal"
+                            "type": "string"
                         }
                     },
                     "400": {
-                        "description": "获取失败",
+                        "description": "上传失败",
                         "schema": {
                             "type": "string"
                         }
@@ -1319,30 +1341,21 @@
                 }
             }
         },
-        "/question/reply/upload_audio": {
-            "post": {
-                "description": "上传回复音频",
+        "/question/unread": {
+            "get": {
+                "description": "我的问答未读数",
                 "tags": [
                     "问答社区模块"
                 ],
-                "parameters": [
-                    {
-                        "type": "string",
-                        "description": "音频文件",
-                        "name": "file",
-                        "in": "query",
-                        "required": true
-                    }
-                ],
                 "responses": {
                     "200": {
-                        "description": "上传成功",
+                        "description": "获取成功",
                         "schema": {
-                            "type": "string"
+                            "type": "int"
                         }
                     },
                     "400": {
-                        "description": "上传失败",
+                        "description": "获取失败",
                         "schema": {
                             "type": "string"
                         }
@@ -2329,10 +2342,8 @@
                 "classifyName": {
                     "type": "string"
                 },
-                "hasPermission": {
-                    "type": "boolean"
-                },
                 "items": {
+                    "description": "HasPermission bool              `description:\"是否有权限\"`",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/company.PermissionItem"
@@ -2343,9 +2354,6 @@
         "company.PermissionItem": {
             "type": "object",
             "properties": {
-                "hasPermission": {
-                    "type": "boolean"
-                },
                 "permissionId": {
                     "type": "integer"
                 },
@@ -2608,7 +2616,7 @@
                 }
             }
         },
-        "response.CommunityReplyTotal": {
+        "response.CommunityQuestionListTotal": {
             "type": "object",
             "properties": {
                 "replied": {

+ 30 - 25
docs/swagger.yaml

@@ -346,17 +346,14 @@ definitions:
     properties:
       classifyName:
         type: string
-      hasPermission:
-        type: boolean
       items:
+        description: HasPermission bool              `description:"是否有权限"`
         items:
           $ref: '#/definitions/company.PermissionItem'
         type: array
     type: object
   company.PermissionItem:
     properties:
-      hasPermission:
-        type: boolean
       permissionId:
         type: integer
       permissionName:
@@ -531,7 +528,7 @@ definitions:
       user_id:
         type: integer
     type: object
-  response.CommunityReplyTotal:
+  response.CommunityQuestionListTotal:
     properties:
       replied:
         type: integer
@@ -1578,6 +1575,20 @@ paths:
             type: string
       tags:
       - 问答社区模块
+  /question/list/total:
+    get:
+      description: 问答列表数量统计
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.CommunityQuestionListTotal'
+        "400":
+          description: 获取失败
+          schema:
+            type: string
+      tags:
+      - 问答社区模块
   /question/reply:
     post:
       description: 发布回复
@@ -1623,26 +1634,6 @@ paths:
             type: string
       tags:
       - 问答社区模块
-  /question/reply/total:
-    get:
-      description: 问答列表数量统计
-      parameters:
-      - description: 回复人ID
-        in: query
-        name: replier_user_id
-        required: true
-        type: integer
-      responses:
-        "200":
-          description: OK
-          schema:
-            $ref: '#/definitions/response.CommunityReplyTotal'
-        "400":
-          description: 获取失败
-          schema:
-            type: string
-      tags:
-      - 问答社区模块
   /question/reply/upload_audio:
     post:
       description: 上传回复音频
@@ -1663,6 +1654,20 @@ paths:
             type: string
       tags:
       - 问答社区模块
+  /question/unread:
+    get:
+      description: 我的问答未读数
+      responses:
+        "200":
+          description: 获取成功
+          schema:
+            type: int
+        "400":
+          description: 获取失败
+          schema:
+            type: string
+      tags:
+      - 问答社区模块
   /report/research_report:
     get:
       consumes:

+ 14 - 11
logic/user/user.go

@@ -343,21 +343,24 @@ func Apply(userId int, companyId int64, mobile, email string, applyInfo userReq.
 
 // GetUserTabBar 获取用户小程序TabBar
 func GetUserTabBar(userInfo user.UserInfo, version string) (list []string, err error) {
-	// user-我的; activity-活动; chart-图表; report-研报; buy-已购
+	// user-我的; activity-活动; chart-图表; report-研报; buy-已购; question-问答;
 	list = []string{"activity", "user", "chart"}
 	if version == "yb3.0" {
 		list = []string{"activity", "user", "chart", "report"}
-		companyProduct, tmpErr := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
-		if tmpErr != nil {
-			if tmpErr == utils.ErrNoRow {
-				err = nil
-			}
-			return
-		}
-		// 已购仅付费用户可见
-		if strings.Contains("永续,正式", companyProduct.Status) {
-			list = append(list, "buy")
+	}
+	if version == "yb5.0" {
+		list = []string{"activity", "question", "chart", "report"}
+	}
+	companyProduct, tmpErr := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
+	if tmpErr != nil {
+		if tmpErr == utils.ErrNoRow {
+			err = nil
 		}
+		return
+	}
+	// 已购仅付费用户可见
+	if strings.Contains("永续,正式", companyProduct.Status) {
+		list = append(list, "buy")
 	}
 	return
 }

+ 0 - 1
models/request/community.go

@@ -6,7 +6,6 @@ type QuestionListReq struct {
 	OnlyMine          int `json:"only_mine" form:"only_mine"`
 	ChartPermissionId int `json:"chart_permission_id" form:"chart_permission_id"`
 	ReplyStatus       int `json:"reply_status" form:"reply_status"`
-	ReplierUserId     int `json:"replier_user_id" form:"replier_user_id"`
 }
 
 type QuestionDetailReq struct {

+ 1 - 1
models/response/community.go

@@ -26,7 +26,7 @@ type CommunityQuestionAudioItem struct {
 	Sort                int    `json:"sort"`
 }
 
-type CommunityReplyTotal struct {
+type CommunityQuestionListTotal struct {
 	Wait    int `json:"wait"`
 	Replied int `json:"replied"`
 	Total   int `json:"total"`

+ 3 - 0
models/tables/yb_community_question/entity.go

@@ -26,6 +26,7 @@ type YbCommunityQuestion struct {
 	ChartPermissionID       int       `gorm:"index:idx_chart_permission_id;column:chart_permission_id;type:int(10) unsigned;not null;default:0" json:"chartPermissionId"` // 关联权限ID
 	ChartPermissionName     string    `gorm:"column:chart_permission_name;type:varchar(100);not null;default:''" json:"chartPermissionName"`                              // 关联权限name
 	IsRead                  int       `gorm:"column:is_read;type:tinyint(4) unsigned;not null;default:0" json:"isRead"`                                                   // 用户是否已读 0-未读 1-已读
+	ReplierIsRead           int       `gorm:"column:replier_is_read;type:tinyint(4) unsigned;not null;default:0" json:"replierIsRead"`                                    // 回复人是否已读 0-未读 1-已读
 	ReplyStatus             int       `gorm:"column:reply_status;type:tinyint(4) unsigned;not null;default:0" json:"replyStatus"`                                         // 回复状态 1-待分配 2-待回答 3-已回答
 	MsgSendStatus           int       `gorm:"column:msg_send_status;type:tinyint(4) unsigned;not null;default:0" json:"msgSendStatus"`                                    // 消息推送进度 0-待推送 1-已推送回答人 2-已推送提问人
 	ReplyTime               time.Time `gorm:"column:reply_time;type:datetime" json:"replyTime"`                                                                           // 回复时间
@@ -62,6 +63,7 @@ var YbCommunityQuestionColumns = struct {
 	ChartPermissionID       string
 	ChartPermissionName     string
 	IsRead                  string
+	ReplierIsRead           string
 	ReplyStatus             string
 	MsgSendStatus           string
 	ReplyTime               string
@@ -90,6 +92,7 @@ var YbCommunityQuestionColumns = struct {
 	ChartPermissionID:       "chart_permission_id",
 	ChartPermissionName:     "chart_permission_name",
 	IsRead:                  "is_read",
+	ReplierIsRead:           "replier_is_read",
 	ReplyStatus:             "reply_status",
 	MsgSendStatus:           "msg_send_status",
 	ReplyTime:               "reply_time",

+ 23 - 10
models/tables/yb_community_question/model.go

@@ -17,6 +17,7 @@ func (item *YbCommunityQuestion) Update(updateCols []string) (err error) {
 	return
 }
 
+// GetPageListByCondition 获取问答列表-分页
 func GetPageListByCondition(where map[string]interface{}, pageIndex, pageSize int) (list []*YbCommunityQuestion, err error) {
 	cond, vals, e := utils.WhereBuild(where)
 	if e != nil {
@@ -28,13 +29,7 @@ func GetPageListByCondition(where map[string]interface{}, pageIndex, pageSize in
 	return
 }
 
-func GetWaitingReplyNum(replierId int) (num int64, err error) {
-	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestion{}).
-		Where("replier_user_id =", replierId).
-		Count(&num).Error
-	return
-}
-
+// GetItemById 主键获取问答信息
 func GetItemById(questionId int) (item *YbCommunityQuestion, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestion{}).
 		Where("community_question_id = ? AND is_deleted = 0", questionId).
@@ -42,6 +37,7 @@ func GetItemById(questionId int) (item *YbCommunityQuestion, err error) {
 	return
 }
 
+// UpdateQuestionAndAudioList 更新问答及音频
 func UpdateQuestionAndAudioList(item *YbCommunityQuestion, updateCols []string, audioList []*yb_community_question_audio.YbCommunityQuestionAudio) (err error) {
 	tx := global.DEFAULT_MYSQL.Begin()
 	defer func() {
@@ -64,16 +60,33 @@ func UpdateQuestionAndAudioList(item *YbCommunityQuestion, updateCols []string,
 	return
 }
 
-type ReplierQuestionCount struct {
+type QuestionListCount struct {
 	ReplyStatus int `json:"reply_status"`
 	Total       int `json:"total"`
 }
 
-func GetReplierQuestionCount(replierUserId int) (list []*ReplierQuestionCount, err error) {
+// GetQuestionListCount 获取问答数量统计
+func GetQuestionListCount(where map[string]interface{}) (list []*QuestionListCount, err error) {
+	cond, vals, e := utils.WhereBuild(where)
+	if e != nil {
+		err = errors.New("系统异常,GetQuestionListCount 生成查询语句失败")
+		return
+	}
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestion{}).
 		Select("reply_status, COUNT(1) total").
-		Where("replier_user_id = ? AND is_deleted = 0", replierUserId).
+		Where(cond, vals...).
 		Group("reply_status").
 		Scan(&list).Error
 	return
 }
+
+// GetUnreadNum 获取未读数
+func GetUnreadNum(where map[string]interface{}) (num int64, err error) {
+	cond, vals, e := utils.WhereBuild(where)
+	if e != nil {
+		err = errors.New("系统异常,GetUnreadNum 生成查询语句失败")
+		return
+	}
+	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestion{}).Where(cond, vals...).Count(&num).Error
+	return
+}

+ 2 - 1
routers/community.go

@@ -13,6 +13,7 @@ func InitCommunity(r *gin.Engine)  {
 	rGroup.POST("/question/ask", community.QuestionAsk)
 	rGroup.POST("/question/reply", community.QuestionReply)
 	rGroup.POST("/question/reply/read", community.QuestionReplyRead)
-	rGroup.GET("/question/reply/total", community.QuestionReplyTotal)
+	rGroup.GET("/question/list/total", community.QuestionListTotal)
 	rGroup.POST("/question/reply/upload_audio", community.QuestionUploadAudio)
+	rGroup.GET("/question/unread", community.QuestionUnread)
 }

+ 64 - 26
services/community/question.go

@@ -16,7 +16,7 @@ import (
 )
 
 // GetQuestionList 获取问答列表
-func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStatus, replierUserId int, userInfo user.UserInfo) (resp []*response.CommunityQuestionItem, err error) {
+func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStatus int, userInfo user.UserInfo) (resp []*response.CommunityQuestionItem, err error) {
 	condition := make(map[string]interface{})
 	condition["is_deleted ="] = 0
 	// 用户身份
@@ -25,25 +25,16 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
 		err = errors.New("获取用户身份失败 Err:" + e.Error())
 		return
 	}
-	if replierUserId > 0 {
-		condition["replier_user_id ="] = replierUserId
-		// 回复列表
-		if replyStatus > 0 {
-			condition["reply_status ="] = replyStatus
-		}
-	} else {
-		// 问题列表
-		if onlyMine == 1 {
-			if isAdmin {
-				condition["replier_user_id ="] = userInfo.UserID
-			} else {
-				condition["user_id ="] = userInfo.UserID
-			}
+	if onlyMine == 1 {
+		if isAdmin {
+			condition["replier_user_id ="] = userInfo.UserID
 		} else {
-			// 默认只展示已回复的
-			condition["reply_status ="] = 3
+			condition["user_id ="] = userInfo.UserID
 		}
 	}
+	if replyStatus > 0 {
+		condition["reply_status ="] = replyStatus
+	}
 	if chartPermissionId > 0 {
 		condition["chart_permission_id ="] = chartPermissionId
 	}
@@ -240,19 +231,30 @@ func ReplyUserQuestion(replierId, questionId int, audios []*request.ReplyReqAudi
 }
 
 // ReadQuestionReply 回复已读
-func ReadQuestionReply(userId int, questionId int) (err error) {
+func ReadQuestionReply(questionId int, userInfo user.UserInfo) (err error) {
 	item, e := yb_community_question.GetItemById(questionId)
 	if e != nil {
 		err = errors.New("获取提问信息失败 Err:" + e.Error())
 		return
 	}
-	if item.IsRead == 1 {
+	if item.IsRead == 1 && item.ReplierIsRead == 1 {
 		return
 	}
-	if item.UserID == userId {
+	if item.UserID == int(userInfo.UserID) {
+		isAdmin, _, e := user.GetAdminByUserInfo(userInfo)
+		if e != nil {
+			err = errors.New("获取用户身份失败 Err:" + e.Error())
+			return
+		}
 		updateCols := make([]string, 0)
-		updateCols = append(updateCols, "is_read", "modify_time")
-		item.IsRead = 1
+		updateCols = append(updateCols, "modify_time")
+		if isAdmin {
+			updateCols = append(updateCols, "replier_is_read")
+			item.ReplierIsRead = 1
+		} else {
+			updateCols = append(updateCols, "is_read")
+			item.IsRead = 1
+		}
 		item.ModifyTime = time.Now().Local()
 		if e = item.Update(updateCols); e != nil {
 			err = errors.New("更新问题已读失败 Err:" + e.Error())
@@ -261,14 +263,26 @@ func ReadQuestionReply(userId int, questionId int) (err error) {
 	return
 }
 
-// GetReplyListTotal 获取问答列表数量统计
-func GetReplyListTotal(replierUserId int) (resp *response.CommunityReplyTotal, err error) {
-	countList, e := yb_community_question.GetReplierQuestionCount(replierUserId)
+// GetQuestionListTotal 获取问答列表数量统计
+func GetQuestionListTotal(userInfo user.UserInfo) (resp *response.CommunityQuestionListTotal, err error) {
+	isAdmin, _, e := user.GetAdminByUserInfo(userInfo)
+	if e != nil {
+		err = errors.New("获取用户身份失败 Err:" + e.Error())
+		return
+	}
+	condition := make(map[string]interface{}, 0)
+	condition["is_deleted ="] = 0
+	if isAdmin {
+		condition["replier_user_id ="] = userInfo.UserID
+	} else {
+		condition["user_id ="] = userInfo.UserID
+	}
+	countList, e := yb_community_question.GetQuestionListCount(condition)
 	if e != nil {
 		err = errors.New("获取回复人问题统计失败 Err:" + e.Error())
 		return
 	}
-	resp = new(response.CommunityReplyTotal)
+	resp = new(response.CommunityQuestionListTotal)
 	for _, v := range countList {
 		if v.ReplyStatus == 2 {
 			resp.Wait = v.Total
@@ -281,3 +295,27 @@ func GetReplyListTotal(replierUserId int) (resp *response.CommunityReplyTotal, e
 	resp.Total = resp.Wait + resp.Replied
 	return
 }
+
+// GetMyQuestionUnread 获取我的未读数
+func GetMyQuestionUnread(userInfo user.UserInfo) (total int, err error) {
+	isAdmin, _, e := user.GetAdminByUserInfo(userInfo)
+	if e != nil {
+		err = errors.New("获取用户身份失败 Err:" + e.Error())
+		return
+	}
+	condition := make(map[string]interface{}, 0)
+	if isAdmin {
+		condition["replier_user_id ="] = userInfo.UserID
+		condition["replier_is_read ="] = 0
+	} else {
+		condition["user_id ="] = userInfo.UserID
+		condition["is_read ="] = 0
+	}
+	num, e := yb_community_question.GetUnreadNum(condition)
+	if e != nil {
+		err = errors.New("获取我的未读数失败 Err:" + e.Error())
+		return
+	}
+	total = int(num)
+	return
+}

+ 8 - 4
services/sms.go

@@ -31,8 +31,10 @@ func SendSmsCode(mobile, vCode string) bool {
 		fmt.Printf("接口返回result字段是:\r\n%v", netReturn["result"])
 		flag = true
 	} else {
-		//go SendEmail("短信验证码发送失败", " result"+string(result), utils.EmailSendToUsers)
-		go alarm_msg.SendAlarmMsg("短信验证码发送失败, Result:"+string(result), 2)
+		// 忽略错误的手机号码这种错误
+		if netReturn["error_code"].(float64) != 205401 {
+			go alarm_msg.SendAlarmMsg("短信验证码发送失败, Result:"+string(result), 2)
+		}
 		flag = false
 	}
 	return flag
@@ -86,8 +88,10 @@ func SendSmsCodeGj(mobile, vCode, areaNum string) bool {
 		fmt.Printf("接口返回result字段是:\r\n%v", netReturn["result"])
 		flag = true
 	} else {
-		//go SendEmail("短信验证码发送失败", " result"+string(result), utils.EmailSendToUsers)
-		go alarm_msg.SendAlarmMsg("短信验证码发送失败, Result:"+string(result), 2)
+		// 忽略错误的手机号码这种错误
+		if netReturn["error_code"].(float64) != 205401 {
+			go alarm_msg.SendAlarmMsg("短信验证码发送失败, Result:"+string(result), 2)
+		}
 		flag = false
 	}
 	return flag