|
@@ -1,8 +1,11 @@
|
|
-//部门管理
|
|
|
|
|
|
+// 部门管理
|
|
package department
|
|
package department
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
"database/sql"
|
|
"database/sql"
|
|
|
|
+ "entbase/src/config"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jypkg/ent/entity"
|
|
. "app.yhyue.com/moapp/jypkg/ent/entity"
|
|
@@ -40,7 +43,7 @@ type PcPersons struct {
|
|
Role string `xorm:"role" json:"role"` //人员角色
|
|
Role string `xorm:"role" json:"role"` //人员角色
|
|
}
|
|
}
|
|
|
|
|
|
-//新增
|
|
|
|
|
|
+// 新增
|
|
func (a *Action) Add() {
|
|
func (a *Action) Add() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "name", "pid") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "name", "pid") {
|
|
return
|
|
return
|
|
@@ -71,7 +74,7 @@ func (a *Action) Add() {
|
|
a.ServeJson(Result{Data: M{"status": status, "id": dept_id}})
|
|
a.ServeJson(Result{Data: M{"status": status, "id": dept_id}})
|
|
}
|
|
}
|
|
|
|
|
|
-//删除
|
|
|
|
|
|
+// 删除
|
|
func (a *Action) Del() {
|
|
func (a *Action) Del() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
return
|
|
return
|
|
@@ -90,7 +93,7 @@ func (a *Action) Del() {
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
}
|
|
}
|
|
|
|
|
|
-//移动
|
|
|
|
|
|
+// 移动
|
|
func (a *Action) Move() {
|
|
func (a *Action) Move() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "pid") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "pid") {
|
|
return
|
|
return
|
|
@@ -113,7 +116,7 @@ func (a *Action) Move() {
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
}
|
|
}
|
|
|
|
|
|
-//详情
|
|
|
|
|
|
+// 详情
|
|
func (a *Action) Detail() {
|
|
func (a *Action) Detail() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
return
|
|
return
|
|
@@ -135,7 +138,7 @@ func (a *Action) Detail() {
|
|
}})
|
|
}})
|
|
}
|
|
}
|
|
|
|
|
|
-//修改
|
|
|
|
|
|
+// 修改
|
|
func (a *Action) Update() {
|
|
func (a *Action) Update() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "name", "pid") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id", "name", "pid") {
|
|
return
|
|
return
|
|
@@ -154,15 +157,33 @@ func (a *Action) Update() {
|
|
}
|
|
}
|
|
name := a.GetString("name")
|
|
name := a.GetString("name")
|
|
status := 0
|
|
status := 0
|
|
|
|
+ clearDepartAdminCache(id) // 旧部门管理员的缓存
|
|
if VarDepartment.UpdateIsExists(name, frameworkEntId, id) {
|
|
if VarDepartment.UpdateIsExists(name, frameworkEntId, id) {
|
|
status = -1
|
|
status = -1
|
|
} else if VarDepartment.Update(name, id, pid, aid, frameworkEntId) {
|
|
} else if VarDepartment.Update(name, id, pid, aid, frameworkEntId) {
|
|
status = 1
|
|
status = 1
|
|
}
|
|
}
|
|
|
|
+ clearDepartAdminCache(id) // 新部门管理员的缓存
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
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() {
|
|
func (a *Action) Persons() {
|
|
frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
|
|
frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
|
|
currentUser := VarCurrentUser.EntInfo(frameworkEntId, qutil.IntAll(a.GetSession("entUserId")))
|
|
currentUser := VarCurrentUser.EntInfo(frameworkEntId, qutil.IntAll(a.GetSession("entUserId")))
|
|
@@ -187,7 +208,7 @@ func (a *Action) Persons() {
|
|
a.ServeJson(Result{Data: persons})
|
|
a.ServeJson(Result{Data: persons})
|
|
}
|
|
}
|
|
|
|
|
|
-//子部门
|
|
|
|
|
|
+// 子部门
|
|
func (a *Action) Childrens() {
|
|
func (a *Action) Childrens() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
return
|
|
return
|
|
@@ -210,7 +231,7 @@ func (a *Action) Childrens() {
|
|
a.ServeJson(Result{Data: depts})
|
|
a.ServeJson(Result{Data: depts})
|
|
}
|
|
}
|
|
|
|
|
|
-//所有子部门
|
|
|
|
|
|
+// 所有子部门
|
|
func (a *Action) AllChildrens() {
|
|
func (a *Action) AllChildrens() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "id") {
|
|
return
|
|
return
|
|
@@ -233,7 +254,7 @@ func (a *Action) AllChildrens() {
|
|
a.ServeJson(Result{Data: depts})
|
|
a.ServeJson(Result{Data: depts})
|
|
}
|
|
}
|
|
|
|
|
|
-//设置部门管理员
|
|
|
|
|
|
+// 设置部门管理员
|
|
func (a *Action) SetAdmin() {
|
|
func (a *Action) SetAdmin() {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "did", "aid") {
|
|
if !R.CheckReqParam(a.ResponseWriter, a.Request, "did", "aid") {
|
|
return
|
|
return
|
|
@@ -250,15 +271,17 @@ func (a *Action) SetAdmin() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
status := 0
|
|
status := 0
|
|
|
|
+ clearDepartAdminCache(did) // 旧部门管理员缓存
|
|
if Mysql.ExecTx("设置部门管理员", func(tx *sql.Tx) bool {
|
|
if Mysql.ExecTx("设置部门管理员", func(tx *sql.Tx) bool {
|
|
return VarDepartment.SetAdmin(tx, frameworkEntId, did, aid)
|
|
return VarDepartment.SetAdmin(tx, frameworkEntId, did, aid)
|
|
}) {
|
|
}) {
|
|
status = 1
|
|
status = 1
|
|
}
|
|
}
|
|
|
|
+ clearDepartAdminCache(did) //新部门管理员缓存
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
a.ServeJson(Result{Data: M{"status": status}})
|
|
}
|
|
}
|
|
|
|
|
|
-//pc部门管理员,选择员工列表
|
|
|
|
|
|
+// pc部门管理员,选择员工列表
|
|
func (a *Action) PcPersons() {
|
|
func (a *Action) PcPersons() {
|
|
frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
|
|
frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
|
|
name := a.GetString("name")
|
|
name := a.GetString("name")
|