wcj 5 년 전
부모
커밋
37c74cd84b
2개의 변경된 파일23개의 추가작업 그리고 18개의 파일을 삭제
  1. 23 16
      src/jfw/modules/entniche/src/entity/entity.go
  2. 0 2
      src/jfw/modules/entniche/src/filter/sessionfilter.go

+ 23 - 16
src/jfw/modules/entniche/src/entity/entity.go

@@ -86,25 +86,32 @@ func (c *CurrentUser) EntInfo(userId string, entId int) *CurrentUser {
 	if phone == "" {
 		return currentUser
 	}
-	//角色、权限
-	r := Mysql.SelectBySql(`SELECT b.role_id,c.dept_id,d.name as dept_name,d.subdis as dept_subdis from entniche_user a 
-		LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
-		LEFT JOIN entniche_department_user c on (a.id=c.user_id) 
-		LEFT JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
-		where a.ent_id=? and a.phone=? order by a.id desc`, entId, entId, phone)
-	if r != nil && len(*r) > 0 {
-		role_id := qutil.IntAll((*r)[0]["role_id"])
-		if role_id == Role_admin_department {
-			currentUser.Role_admin_department = true
-		}
-		currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
-		currentUser.Dept.Name = (*r)[0]["dept_name"].(string)
-		currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
-	}
-	//
 	currentUser.Ent = VarEntInfo.GetById(entId)
 	if currentUser.Ent.Phone == phone {
 		currentUser.Role_admin_system = true
+		r := Mysql.SelectBySql(`SELECT id,name,subdis from entniche_department where ent_id=? and pid=0`, entId)
+		if r != nil && len(*r) > 0 {
+			department := JsonUnmarshal((*r)[0], &Department{}).(*Department)
+			if department != nil {
+				currentUser.Dept = department
+			}
+		}
+	} else {
+		//角色、权限
+		r := Mysql.SelectBySql(`SELECT b.role_id,c.dept_id,d.name as dept_name,d.subdis as dept_subdis from entniche_user a 
+			LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
+			LEFT JOIN entniche_department_user c on (a.id=c.user_id) 
+			LEFT JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
+			where a.ent_id=? and a.phone=? order by a.id desc`, entId, entId, phone)
+		if r != nil && len(*r) > 0 {
+			role_id := qutil.IntAll((*r)[0]["role_id"])
+			if role_id == Role_admin_department {
+				currentUser.Role_admin_department = true
+			}
+			currentUser.Dept.Id = qutil.IntAll((*r)[0]["dept_id"])
+			currentUser.Dept.Name = (*r)[0]["dept_name"].(string)
+			currentUser.Dept.Subdis = qutil.IntAll((*r)[0]["dept_subdis"])
+		}
 	}
 	return currentUser
 }

+ 0 - 2
src/jfw/modules/entniche/src/filter/sessionfilter.go

@@ -18,8 +18,6 @@ type sessionfilter struct {
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	session := l.App.SessionManager.Session(req, w)
 	//session.Set("userId", "5d6e142a25ef871f08a72662")
-	//session.Set("entId", 4)
-	//session.Set("entName", "王公子测试企业")
 	if session.Get("userId") == nil {
 		content, _ := json.MarshalIndent(map[string]interface{}{
 			"error_code": Error_code_1001,