“wwangchuanjin 5 年之前
父節點
當前提交
33a8e773c3

+ 23 - 23
entbase/src/service/department/department.go

@@ -33,8 +33,8 @@ func (a *Action) Add() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "pid")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "pid")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, pid) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, pid) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
@@ -42,11 +42,11 @@ func (a *Action) Add() {
 	name := a.GetString("name")
 	name := a.GetString("name")
 	status := 0
 	status := 0
 	var dept_id int64
 	var dept_id int64
-	if VarDepartment.AddIsExists(name, entId) {
+	if VarDepartment.AddIsExists(name, frameworkEntId) {
 		status = -1
 		status = -1
 	} else {
 	} else {
 		aid, _ := a.GetInteger("aid")
 		aid, _ := a.GetInteger("aid")
-		dept_id = VarDepartment.Add(name, pid, aid, entId)
+		dept_id = VarDepartment.Add(name, pid, aid, frameworkEntId)
 		if dept_id > 0 {
 		if dept_id > 0 {
 			status = 1
 			status = 1
 		}
 		}
@@ -60,14 +60,14 @@ func (a *Action) Del() {
 		return
 		return
 	}
 	}
 	id := a.GetString("id")
 	id := a.GetString("id")
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, id) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, id) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	//
 	//
 	status := 0
 	status := 0
-	if VarDepartment.Del(entId, id) {
+	if VarDepartment.Del(frameworkEntId, id) {
 		status = 1
 		status = 1
 	}
 	}
 	a.ServeJson(Result{Data: M{"status": status}})
 	a.ServeJson(Result{Data: M{"status": status}})
@@ -84,13 +84,13 @@ func (a *Action) Move() {
 		return
 		return
 	}
 	}
 	id := a.GetString("id")
 	id := a.GetString("id")
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, pid, id) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, pid, id) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	status := 0
 	status := 0
-	if VarDepartment.Move(entId, pid, id) {
+	if VarDepartment.Move(frameworkEntId, pid, id) {
 		status = 1
 		status = 1
 	}
 	}
 	a.ServeJson(Result{Data: M{"status": status}})
 	a.ServeJson(Result{Data: M{"status": status}})
@@ -106,8 +106,8 @@ func (a *Action) Detail() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	dept := VarDepartment.GetAllInfoById(entId, id)
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	dept := VarDepartment.GetAllInfoById(frameworkEntId, id)
 	a.ServeJson(Result{Data: M{
 	a.ServeJson(Result{Data: M{
 		"name":       dept.Name,
 		"name":       dept.Name,
 		"pid":        dept.Pid,
 		"pid":        dept.Pid,
@@ -130,16 +130,16 @@ func (a *Action) Update() {
 		return
 		return
 	}
 	}
 	aid, _ := a.GetInteger("aid")
 	aid, _ := a.GetInteger("aid")
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, id, pid) || (aid > 0 && !VarUser.IsMyPerson(entId, aid)) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, id, pid) || (aid > 0 && !VarUser.IsMyPerson(frameworkEntId, aid)) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	name := a.GetString("name")
 	name := a.GetString("name")
 	status := 0
 	status := 0
-	if VarDepartment.UpdateIsExists(name, entId, id) {
+	if VarDepartment.UpdateIsExists(name, frameworkEntId, id) {
 		status = -1
 		status = -1
-	} else if VarDepartment.Update(name, id, pid, aid, entId) {
+	} else if VarDepartment.Update(name, id, pid, aid, frameworkEntId) {
 		status = 1
 		status = 1
 	}
 	}
 	a.ServeJson(Result{Data: M{"status": status}})
 	a.ServeJson(Result{Data: M{"status": status}})
@@ -147,9 +147,9 @@ func (a *Action) Update() {
 
 
 //设置部门管理员,选择员工列表
 //设置部门管理员,选择员工列表
 func (a *Action) Persons() {
 func (a *Action) Persons() {
-	entId := qutil.IntAll(a.GetSession("entId"))
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
 	persons := []M{}
 	persons := []M{}
-	for _, v := range *VarEntInfo.GetUsersExcludeAdmin(entId) {
+	for _, v := range *VarEntInfo.GetUsersExcludeAdmin(frameworkEntId) {
 		persons = append(persons, M{
 		persons = append(persons, M{
 			"id":    v.Id,
 			"id":    v.Id,
 			"name":  v.Name,
 			"name":  v.Name,
@@ -170,9 +170,9 @@ func (a *Action) Childrens() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
 	depts := []M{}
 	depts := []M{}
-	for _, v := range *VarDepartment.GetChildrens(entId, id) {
+	for _, v := range *VarDepartment.GetChildrens(frameworkEntId, id) {
 		depts = append(depts, M{
 		depts = append(depts, M{
 			"id":         v.Id,
 			"id":         v.Id,
 			"name":       v.Name,
 			"name":       v.Name,
@@ -193,14 +193,14 @@ func (a *Action) SetAdmin() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "did", "aid")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "did", "aid")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, did) || !VarUser.IsMyPerson(entId, aid) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, did) || !VarUser.IsMyPerson(frameworkEntId, aid) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	status := 0
 	status := 0
 	if Mysql.ExecTx("设置部门管理员", func(tx *sql.Tx) bool {
 	if Mysql.ExecTx("设置部门管理员", func(tx *sql.Tx) bool {
-		return VarDepartment.SetAdmin(tx, entId, did, aid)
+		return VarDepartment.SetAdmin(tx, frameworkEntId, did, aid)
 	}) {
 	}) {
 		status = 1
 		status = 1
 	}
 	}

+ 9 - 3
entbase/src/service/ent/ent.go

@@ -90,7 +90,7 @@ func (a *Action) SelectEnt() {
 			R.NoPermissionReq(a.ResponseWriter, a.Request)
 			R.NoPermissionReq(a.ResponseWriter, a.Request)
 			return
 			return
 		}
 		}
-		SetSess(a.Session(), ent["id"], ent["name"], ent["user_id"])
+		SetSess(a.Session(), ent["id"], ent["name"], ent["user_id"], false)
 	}
 	}
 	a.ServeJson(Result{Data: M{"status": 1}})
 	a.ServeJson(Result{Data: M{"status": 1}})
 }
 }
@@ -106,7 +106,7 @@ func (a *Action) Framework() {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
-	SetSess(a.Session(), ent["id"], ent["name"], ent["user_id"])
+	SetSess(a.Session(), ent["id"], ent["name"], ent["user_id"], true)
 	a.ServeJson(Result{Data: M{"status": 1}})
 	a.ServeJson(Result{Data: M{"status": 1}})
 }
 }
 
 
@@ -204,13 +204,19 @@ func (a *Action) Add() {
 }
 }
 
 
 /****************************************************/
 /****************************************************/
-func SetSess(sess *httpsession.Session, entId, entName, entUserId interface{}) {
+func SetSess(sess *httpsession.Session, entId, entName, entUserId interface{}, framework bool) {
 	sess.Set("entId", entId)
 	sess.Set("entId", entId)
 	sess.Set("entName", entName)
 	sess.Set("entName", entName)
 	sess.Set("entUserId", entUserId)
 	sess.Set("entUserId", entUserId)
+	if framework {
+		sess.Set("frameworkEntId", entId)
+		sess.Set("frameworkEntName", entName)
+	}
 }
 }
 func ClearSess(sess *httpsession.Session) {
 func ClearSess(sess *httpsession.Session) {
 	sess.Del("entId")
 	sess.Del("entId")
 	sess.Del("entName")
 	sess.Del("entName")
 	sess.Del("entUserId")
 	sess.Del("entUserId")
+	sess.Del("frameworkEntId")
+	sess.Del("frameworkEntName")
 }
 }

+ 25 - 25
entbase/src/service/person/person.go

@@ -33,14 +33,14 @@ func (a *Action) Manager() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	dept := VarDepartment.GetById(entId, id)
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	dept := VarDepartment.GetById(frameworkEntId, id)
 	if dept.Id == 0 {
 	if dept.Id == 0 {
-		R.NoPermissionReq(a.ResponseWriter, a.Request, fmt.Sprintf("没有找到该部门,企业id %d,部门id %d", entId, id))
+		R.NoPermissionReq(a.ResponseWriter, a.Request, fmt.Sprintf("没有找到该部门,企业id %d,部门id %d", frameworkEntId, id))
 		return
 		return
 	}
 	}
-	entName, _ := a.GetSession("entName").(string)
-	entInfo := VarEntInfo.GetById(entId)
+	frameworkEntName, _ := a.GetSession("frameworkEntName").(string)
+	entInfo := VarEntInfo.GetById(frameworkEntId)
 	var quota int
 	var quota int
 	var added int64
 	var added int64
 	//
 	//
@@ -50,9 +50,9 @@ func (a *Action) Manager() {
 	department = dept.Name
 	department = dept.Name
 	if dept.Pid == 0 {
 	if dept.Pid == 0 {
 		quota = entInfo.Quota
 		quota = entInfo.Quota
-		added = Mysql.CountBySql("select count(1) from entniche_user where ent_id=?", entId)
+		added = Mysql.CountBySql("select count(1) from entniche_user where ent_id=?", frameworkEntId)
 	}
 	}
-	for _, v := range *VarDepartment.GetUsers(entId, id) {
+	for _, v := range *VarDepartment.GetUsers(frameworkEntId, id) {
 		persons = append(persons, M{
 		persons = append(persons, M{
 			"id":    v.Id,
 			"id":    v.Id,
 			"name":  v.Name,
 			"name":  v.Name,
@@ -60,7 +60,7 @@ func (a *Action) Manager() {
 			"role":  v.Role,
 			"role":  v.Role,
 		})
 		})
 	}
 	}
-	for _, v := range *VarDepartment.GetDeptAndUser(entId, id) {
+	for _, v := range *VarDepartment.GetDeptAndUser(frameworkEntId, id) {
 		departments = append(departments, M{
 		departments = append(departments, M{
 			"id":         v.Id,
 			"id":         v.Id,
 			"name":       v.Name,
 			"name":       v.Name,
@@ -70,7 +70,7 @@ func (a *Action) Manager() {
 	}
 	}
 	a.ServeJson(Result{
 	a.ServeJson(Result{
 		Data: M{
 		Data: M{
-			"entname":     entName,
+			"entname":     frameworkEntName,
 			"department":  department,
 			"department":  department,
 			"quota":       quota,
 			"quota":       quota,
 			"added":       added,
 			"added":       added,
@@ -90,8 +90,8 @@ func (a *Action) Add() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, id) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, id) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
@@ -100,14 +100,14 @@ func (a *Action) Add() {
 	phone := a.GetString("phone")
 	phone := a.GetString("phone")
 	mail := a.GetString("mail")
 	mail := a.GetString("mail")
 	status, user_id := func() (int, int64) {
 	status, user_id := func() (int, int64) {
-		if VarUser.AddIsExists(entId, phone) {
+		if VarUser.AddIsExists(frameworkEntId, phone) {
 			return -1, 0
 			return -1, 0
 		} else if VarEntInfo.UserInEntLimit(phone, Config.UserInEntLimit) {
 		} else if VarEntInfo.UserInEntLimit(phone, Config.UserInEntLimit) {
 			return -2, 0
 			return -2, 0
 		}
 		}
 		var user_id int64
 		var user_id int64
 		if Mysql.ExecTx("新增员工", func(tx *sql.Tx) bool {
 		if Mysql.ExecTx("新增员工", func(tx *sql.Tx) bool {
-			uid, ok := VarUser.Add(tx, userId, entId, &User{
+			uid, ok := VarUser.Add(tx, userId, frameworkEntId, &User{
 				Dept_id: id,
 				Dept_id: id,
 				Name:    name,
 				Name:    name,
 				Mail:    mail,
 				Mail:    mail,
@@ -135,14 +135,14 @@ func (a *Action) Del() {
 		return
 		return
 	}
 	}
 	id := a.GetString("id")
 	id := a.GetString("id")
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarUser.IsMyPerson(entId, id) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarUser.IsMyPerson(frameworkEntId, id) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	//
 	//
 	status := 0
 	status := 0
-	if VarUser.Del(entId, id) {
+	if VarUser.Del(frameworkEntId, id) {
 		status = 1
 		status = 1
 	}
 	}
 	a.ServeJson(Result{Data: M{"status": status}})
 	a.ServeJson(Result{Data: M{"status": status}})
@@ -158,16 +158,16 @@ func (a *Action) Move() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "did")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "did")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
 	ids := a.GetString("id")
 	ids := a.GetString("id")
-	if !VarDepartment.IsMyDept(entId, did) || !VarUser.IsMyPerson(entId, ids) {
+	if !VarDepartment.IsMyDept(frameworkEntId, did) || !VarUser.IsMyPerson(frameworkEntId, ids) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	//
 	//
 	status := 0
 	status := 0
 	if Mysql.ExecTx("移动部门", func(tx *sql.Tx) bool {
 	if Mysql.ExecTx("移动部门", func(tx *sql.Tx) bool {
-		return VarUser.Move(tx, entId, did, ids)
+		return VarUser.Move(tx, frameworkEntId, did, ids)
 	}) {
 	}) {
 		status = 1
 		status = 1
 	}
 	}
@@ -184,10 +184,10 @@ func (a *Action) Detail() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	user := VarUser.GetAllInfoById(entId, id)
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	user := VarUser.GetAllInfoById(frameworkEntId, id)
 	if user.Id == 0 {
 	if user.Id == 0 {
-		R.NoPermissionReq(a.ResponseWriter, a.Request, fmt.Sprintf("没有找到该人员,企业id %d,人员id %d", entId, id))
+		R.NoPermissionReq(a.ResponseWriter, a.Request, fmt.Sprintf("没有找到该人员,企业id %d,人员id %d", frameworkEntId, id))
 		return
 		return
 	}
 	}
 	a.ServeJson(Result{
 	a.ServeJson(Result{
@@ -213,13 +213,13 @@ func (a *Action) Update() {
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id", "did")
 		R.InvalidReqParam(a.ResponseWriter, a.Request, "id", "did")
 		return
 		return
 	}
 	}
-	entId := qutil.IntAll(a.GetSession("entId"))
-	if !VarDepartment.IsMyDept(entId, did) || !VarUser.IsMyPerson(entId, id) {
+	frameworkEntId := qutil.IntAll(a.GetSession("frameworkEntId"))
+	if !VarDepartment.IsMyDept(frameworkEntId, did) || !VarUser.IsMyPerson(frameworkEntId, id) {
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		R.NoPermissionReq(a.ResponseWriter, a.Request)
 		return
 		return
 	}
 	}
 	status := 0
 	status := 0
-	if VarUser.Update(a.GetString("mail"), id, did, entId) {
+	if VarUser.Update(a.GetString("mail"), id, did, frameworkEntId) {
 		status = 1
 		status = 1
 	}
 	}
 	a.ServeJson(Result{Data: M{"status": status}})
 	a.ServeJson(Result{Data: M{"status": status}})

+ 15 - 15
pushentniche/src/push/job/pushjob.go

@@ -146,23 +146,23 @@ func (p *PushJob) StartPush(pusher Pusher, taskType int) {
 						continue
 						continue
 					}
 					}
 					logger.Info("推送任务", taskType, "开始推送用户", ui.EntName, ui.EntId, ui.DeptName, ui.DeptId, "id", u.Id, "MId", u.MId, "phone", u.Phone, "jpushid", u.Jpushid, "opushid", u.Opushid, "phoneType", u.AppPhoneType, "rateMode", u.RateMode)
 					logger.Info("推送任务", taskType, "开始推送用户", ui.EntName, ui.EntId, ui.DeptName, ui.DeptId, "id", u.Id, "MId", u.MId, "phone", u.Phone, "jpushid", u.Jpushid, "opushid", u.Opushid, "phoneType", u.AppPhoneType, "rateMode", u.RateMode)
-					if pushWay.AppPush || pushWay.MailPush {
-						//去重 -- start
-						hasPushLock.Lock()
-						exists_key := fmt.Sprintf("%d_%d", u.EntId, u.Id)
-						if hasPushMap[exists_key] {
-							logger.Info("推送任务", taskType, "过滤掉重复推送用户", ui.EntName, ui.EntId, ui.DeptName, ui.DeptId, "id", u.Id, "MId", u.MId, "phone", u.Phone)
-							hasPushLock.Unlock()
-							continue
-						}
-						hasPushMap[exists_key] = true
+					//if pushWay.AppPush || pushWay.MailPush {
+					//去重 -- start
+					hasPushLock.Lock()
+					exists_key := fmt.Sprintf("%d_%d", u.EntId, u.Id)
+					if hasPushMap[exists_key] {
+						logger.Info("推送任务", taskType, "过滤掉重复推送用户", ui.EntName, ui.EntId, ui.DeptName, ui.DeptId, "id", u.Id, "MId", u.MId, "phone", u.Phone)
 						hasPushLock.Unlock()
 						hasPushLock.Unlock()
-						//去重 -- end
-						pr := p.doPush(pusher, taskType, pushWay, u, ToSortList(v["list"]))
-						if pr != nil && pr.PushDate > 0 {
-							pushResult = pr
-						}
+						continue
+					}
+					hasPushMap[exists_key] = true
+					hasPushLock.Unlock()
+					//去重 -- end
+					pr := p.doPush(pusher, taskType, pushWay, u, ToSortList(v["list"]))
+					if pr != nil && pr.PushDate > 0 {
+						pushResult = pr
 					}
 					}
+					//}
 				}
 				}
 				pusher.AfterPush(pushResult, &UserInfo{}, v)
 				pusher.AfterPush(pushResult, &UserInfo{}, v)
 			}(temp, isTake)
 			}(temp, isTake)