فهرست منبع

fix:消息中心一键请空修改&消息列表修改

duxin 2 سال پیش
والد
کامیت
6667b655a7
4فایلهای تغییر یافته به همراه11 افزوده شده و 17 حذف شده
  1. 3 7
      rpc/internal/common/sendMsg.go
  2. 6 4
      rpc/internal/common/sendWxTmplMsg.go
  3. 1 1
      rpc/internal/logic/usermsglistlogic.go
  4. 1 5
      rpc/message.go

+ 3 - 7
rpc/internal/common/sendMsg.go

@@ -219,13 +219,6 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
 			if !this.IsMsgList && !this.IsColumnNewMsg {
 				unread += unreadMsg(this) //仅用于移动端获取所有未读数
 			}
-		} else if this.Read == -1 {
-			unread = entity.Mysql.Count("message", map[string]interface{}{
-				"receive_userid": this.UserId,
-				"isdel":          1,
-				"appid":          this.Appid,
-				"isRead":         0,
-			})
 		}
 	}
 	data.Unread = unread
@@ -233,6 +226,9 @@ func UserMsgList(this *message.UserMsgListReq) *message.UserMsgList {
 }
 
 func unreadMsg(this *message.UserMsgListReq) int64 {
+	if this.PositionId <= 0 {
+		return 0
+	}
 	querySql := fmt.Sprintf("SELECT  b.*,(SELECT SUM( a.unread) FROM  %s a "+
 		"LEFT JOIN %s b ON a.message_id = b.id  "+
 		"WHERE  a.unread > 0 "+

+ 6 - 4
rpc/internal/common/sendWxTmplMsg.go

@@ -22,10 +22,12 @@ type WxTmplPush struct {
 
 const CacheDb = "msgCount"
 
-func MessageType() func() map[string]string {
-	rData := entity.Mysql.SelectBySql("SELECT name,switch FROM message_column")
+func MessageType() (func() map[string]string, []map[string]interface{}) {
+	var data []map[string]interface{}
+	rData := entity.Mysql.SelectBySql("SELECT * FROM message_column ORDER BY sequence ASC")
 	switchName := map[string]string{}
-	if rData == nil && len(*rData) == 0 {
+	if rData != nil && len(*rData) > 0 {
+		data = *rData
 		for _, mData := range *rData {
 			if settingKey, messageName := util.ObjToString(mData["switch"]), util.ObjToString(mData["name"]); settingKey == "" && messageName == "" {
 				switchName[settingKey] = messageName
@@ -34,7 +36,7 @@ func MessageType() func() map[string]string {
 	}
 	return func() map[string]string {
 		return switchName
-	}
+	}, data
 }
 
 var AllMsgType func() map[string]string

+ 1 - 1
rpc/internal/logic/usermsglistlogic.go

@@ -32,7 +32,7 @@ func (l *UserMsgListLogic) UserMsgList(in *message.UserMsgListReq) (*message.Use
 	data := new(message.UserMsgListRes)
 	res1 := service.UserMsgList(in)    //具体信息
 	res2 := service.MessageGetLast(in) //最新信息
-	if res2 != nil || res1.Data != nil {
+	if res2 != nil || res1 != nil {
 		var finalData []*message.Messages
 		if res1.Data != nil {
 			for _, v := range res1.Data {

+ 1 - 5
rpc/message.go

@@ -57,11 +57,7 @@ func init() {
 		MaxIdleConns: config.ConfigJson.DataSource.MaxIdleConns,
 	}
 	entity.Mysql.Init()
-	data := entity.Mysql.Find("message_column", map[string]interface{}{"equity": "message_center"}, "", "sequence", -1, -1)
-	if data != nil && len(*data) > 0 {
-		entity.MessageColumn = *data
-	}
-	common.AllMsgType = common.MessageType()
+	common.AllMsgType, entity.MessageColumn = common.MessageType()
 	//初始化basemysql
 	entity.BaseMysql = &mysql.Mysql{
 		Address:      config.ConfigJson.BaseSource.Address,