浏览代码

fix:优化列表查询

duxin 2 年之前
父节点
当前提交
25d25bfc68
共有 1 个文件被更改,包括 3 次插入7 次删除
  1. 3 7
      service/chat_group.go

+ 3 - 7
service/chat_group.go

@@ -5,8 +5,6 @@ import (
 	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
 	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
 	"fmt"
-	"log"
-	"time"
 )
 
 type ChatGroupService struct{}
@@ -16,7 +14,6 @@ func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, m
 	phoneData := map[string]string{}
 	nameData := map[string]string{}
 	positionData := map[int]string{}
-	tm := time.Now()
 	//在职人员查询
 	personList := IC.MainMysql.SelectBySql(fmt.Sprintf(`SELECT a.phone,IF(a.name = "我" AND b.role_id = 1 ,"%s",a.name)  AS name,b.role_id FROM %s a
 					LEFT JOIN entniche_user_role b on a.id = b.user_id 
@@ -27,7 +24,6 @@ func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, m
 			nameData[common.InterfaceToStr(v["name"])] = common.InterfaceToStr(v["phone"])
 		}
 	}
-	log.Println("查询列表耗时5:", time.Since(tm))
 
 	//离职人员查看
 	if isAll {
@@ -45,17 +41,17 @@ func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, m
 				}
 			}
 		}
-		log.Println("查询列表耗时6:", time.Since(tm))
 
 		//查询企业人员职位
-		positionList := IC.BaseMysql.SelectBySql("SELECT a.phone,b.id FROM base_user a LEFT JOIN base_position b ON a.id = b.user_id WHERE b.ent_id = ?", entId)
+		positionList := IC.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT b.phone,b.id FROM base_position a
+							INNER JOIN base_user b ON a.ent_id = %d
+							AND a.user_id = b.id`, entId))
 		if positionList != nil && len(*positionList) > 0 {
 			for _, v := range *positionList {
 				positionData[common.IntAll(v["id"])] = phoneData[common.ObjToString(v["phone"])]
 			}
 		}
 	}
-	log.Println("查询列表耗时7:", time.Since(tm))
 	return phoneData, nameData, positionData
 }