Эх сурвалжийг харах

Merge branch 'dev/v2.9.25_ws' of jianyu/ent_new into feature/v2.9.25

fuwencai 2 жил өмнө
parent
commit
e2c86fb825

+ 34 - 11
entbase/src/service/department/department.go

@@ -1,8 +1,11 @@
-//部门管理
+// 部门管理
 package department
 
 import (
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
 	"database/sql"
+	"entbase/src/config"
 	"fmt"
 
 	. "app.yhyue.com/moapp/jypkg/ent/entity"
@@ -40,7 +43,7 @@ type PcPersons struct {
 	Role  string `xorm:"role" json:"role"`   //人员角色
 }
 
-//新增
+// 新增
 func (a *Action) Add() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "name", "pid") {
 		return
@@ -71,7 +74,7 @@ func (a *Action) Add() {
 	a.ServeJson(Result{Data: M{"status": status, "id": dept_id}})
 }
 
-//删除
+// 删除
 func (a *Action) Del() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
 		return
@@ -90,7 +93,7 @@ func (a *Action) Del() {
 	a.ServeJson(Result{Data: M{"status": status}})
 }
 
-//移动
+// 移动
 func (a *Action) Move() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "pid") {
 		return
@@ -113,7 +116,7 @@ func (a *Action) Move() {
 	a.ServeJson(Result{Data: M{"status": status}})
 }
 
-//详情
+// 详情
 func (a *Action) Detail() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
 		return
@@ -135,7 +138,7 @@ func (a *Action) Detail() {
 	}})
 }
 
-//修改
+// 修改
 func (a *Action) Update() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "name", "pid") {
 		return
@@ -154,15 +157,33 @@ func (a *Action) Update() {
 	}
 	name := a.GetString("name")
 	status := 0
+	clearDepartAdminCache(id) // 旧部门管理员的缓存
 	if VarDepartment.UpdateIsExists(name, frameworkEntId, id) {
 		status = -1
 	} else if VarDepartment.Update(name, id, pid, aid, frameworkEntId) {
 		status = 1
 	}
+	clearDepartAdminCache(id) // 新部门管理员的缓存
 	a.ServeJson(Result{Data: M{"status": status}})
 }
+func clearDepartAdminCache(deptId int) {
+	// 先清缓存
+	oldUserIdsql := "SELECT        edu.user_id as oldUserId  FROM\n        `entniche_department_user` edu\nINNER JOIN entniche_user_role er ON edu.dept_id = ? AND er.role_id = 2 AND  edu.user_id = er.user_id "
+	oldRs := Mysql.SelectBySql(oldUserIdsql, deptId)
+	if oldRs != nil && len(*oldRs) > 0 {
+		oldUserId := qutil.Int64All((*oldRs)[0]["oldUserId"])
+		oldUserData := config.Middleground.UserCenter.IdentityByEntUserId(oldUserId)
+		positionId := qutil.InterfaceToStr(oldUserData.PositionId)
+		go jy.ClearBigVipUserPower(positionId)
+		go config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
+			PositionId: positionId,
+			AppId:      "10000",
+		})
+		go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
+	}
+}
 
-//设置部门管理员,选择员工列表
+// 设置部门管理员,选择员工列表
 func (a *Action) Persons() {
 	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
 	currentUser := VarCurrentUser.EntInfo(frameworkEntId, qutil.IntAll(a.GetSession("entUserId")))
@@ -187,7 +208,7 @@ func (a *Action) Persons() {
 	a.ServeJson(Result{Data: persons})
 }
 
-//子部门
+// 子部门
 func (a *Action) Childrens() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
 		return
@@ -210,7 +231,7 @@ func (a *Action) Childrens() {
 	a.ServeJson(Result{Data: depts})
 }
 
-//所有子部门
+// 所有子部门
 func (a *Action) AllChildrens() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
 		return
@@ -233,7 +254,7 @@ func (a *Action) AllChildrens() {
 	a.ServeJson(Result{Data: depts})
 }
 
-//设置部门管理员
+// 设置部门管理员
 func (a *Action) SetAdmin() {
 	if !R.CheckReqParam(a.ResponseWriter, a.Request, "did", "aid") {
 		return
@@ -250,15 +271,17 @@ func (a *Action) SetAdmin() {
 		return
 	}
 	status := 0
+	clearDepartAdminCache(did) // 旧部门管理员缓存
 	if Mysql.ExecTx("设置部门管理员", func(tx *sql.Tx) bool {
 		return VarDepartment.SetAdmin(tx, frameworkEntId, did, aid)
 	}) {
 		status = 1
 	}
+	clearDepartAdminCache(did) //新部门管理员缓存
 	a.ServeJson(Result{Data: M{"status": status}})
 }
 
-//pc部门管理员,选择员工列表
+// pc部门管理员,选择员工列表
 func (a *Action) PcPersons() {
 	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
 	name := a.GetString("name")