Browse Source

Merge branch 'dev_v1.2.10.1_wh' of SocialPlatform/messageCenter into hotfix/v1.2.10.1

duxin 1 year ago
parent
commit
e73dfe5f0b
1 changed files with 10 additions and 17 deletions
  1. 10 17
      service/message_mail_box.go

+ 10 - 17
service/message_mail_box.go

@@ -50,7 +50,6 @@ func (b MessaggeService) Count(newUserId, positionId int64) (last map[string]int
 // 用户列表查询
 func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string]interface{}, count int64, err error) {
 	sqlStr := ""
-	countStr := ""
 	tm := time.Now()
 	if in.UserType == 2 {
 		var (
@@ -243,7 +242,6 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		if in.Size <= 0 || in.Size > 100 {
 			in.Size = 50
 		}
-		pageIndex := (in.Page - 1) * in.Size
 		sqlStr = fmt.Sprintf(`SELECT 
     				(
 						CASE
@@ -270,32 +268,27 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 	   				(%s) a
 				LEFT JOIN socialize_message c ON ( a.message_id = c.id )
 			ORDER BY
-			a.timestamp DESC limit %v ,%v`, restrictionSql, pageIndex, in.Size)
-		countStr = fmt.Sprintf(`SELECT  count(1)
+			a.timestamp DESC limit %v ,%v`, restrictionSql, (in.Page-1)*in.Size, in.Size)
+		count = IC.BaseMysql.CountBySql(fmt.Sprintf(`SELECT  count(1)
    				FROM
-	   				(%s) a
-				LEFT JOIN socialize_message c ON ( a.message_id = c.id )
-			ORDER BY
-			a.timestamp DESC`, restrictionSql)
+	   				(%s) a`, restrictionSql))
 	}
 	if sqlStr != "" {
 		log.Println("查询列表sql:", sqlStr)
-		if in.UserType == 1 {
-			count = IC.BaseMysql.CountBySql(countStr)
-		}
 		data = IC.BaseMysql.SelectBySql(sqlStr)
 		if data != nil && len(*data) > 0 {
 			log.Println("查询列表耗时2:", time.Since(tm), in.QueryType, count)
 			switch in.UserType { //客服查询结果分页
 			case 1:
-				/*count = quitl.Int64All(len(*data))
-				if in.Page*in.Size >= count {
-					dataSize = (*data)[(in.Page-1)*in.Size:]
-				} else {
-					dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
-				}*/
+				/*
+					if in.Page*in.Size >= count {
+						dataSize = (*data)[(in.Page-1)*in.Size:]
+					} else {
+						dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
+					}*/
 				return data, count, err
 			case 2: //用户查询结果
+				count = quitl.Int64All(len(*data))
 				phoneMap, _, positionMap := EntPerson(in.EntId, true) //获取企业架构人员名称
 				log.Println("查询列表耗时3:", time.Since(tm))
 				for _, v := range *data {