wcj 5 years ago
parent
commit
430c92f42d
1 changed files with 7 additions and 8 deletions
  1. 7 8
      src/jfw/modules/entniche/src/entity/department.go

+ 7 - 8
src/jfw/modules/entniche/src/entity/department.go

@@ -62,14 +62,13 @@ func (d *Department) GetUsers(ent_id, dept_id int) *[]*User {
 
 //获取部门下所有的员工,包含子部门
 func (d *Department) GetAllUsers(ent_id, dept_id int) *[]*User {
-	r := Mysql.SelectBySql(`select d.id,d.name,d.phone,f.name as role from entniche_department a 
-   		LEFT JOIN entniche_department_parent b on (a.id=b.id) 
-		INNER JOIN entniche_department_user c on (a.id=c.dept_id) 
-		INNER JOIN entniche_user d on (c.user_id=d.id) 
-		LEFT JOIN entniche_user_role e on (d.id=e.user_id) 
-		LEFT JOIN entniche_role f on (e.role_id=f.id) 
-		where (f.id <> 1 or f.id is NULL) and a.ent_id=? and (a.id=? or b.pid=?) 
-		order by convert(d.name using gbk) COLLATE gbk_chinese_ci asc`, ent_id, dept_id, dept_id)
+	r := Mysql.SelectBySql(`select DISTINCT c.id,c.name,c.phone,e.name as role from entniche_department_parent a
+		INNER JOIN entniche_department_user b on (a.id=b.dept_id) 
+		INNER JOIN entniche_user c on (b.user_id=c.id) 
+		LEFT JOIN entniche_user_role d on (c.id=d.user_id) 
+		LEFT JOIN entniche_role e on (d.role_id=e.id) 
+		where (e.id <> 1 or e.id is NULL) and c.ent_id=? and (a.id=? or a.pid=?) 
+		order by convert(c.name using gbk) COLLATE gbk_chinese_ci asc`, ent_id, dept_id, dept_id)
 	users, _ := JsonUnmarshal(r, &[]*User{}).(*[]*User)
 	if users == nil {
 		return &[]*User{}