Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-fb
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王衍超
cloud-fb
Commits
a01aae81
Commit
a01aae81
authored
Apr 15, 2021
by
shiwenbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理部门人员管理与权限管理功能中的部门和人员可选范围
parent
1ad2bf1e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
8 deletions
+111
-8
AuthMgrConstants.java
...java/com/beecode/inz/authmgr/common/AuthMgrConstants.java
+1
-0
AuthManagerDao.java
...main/java/com/beecode/inz/authmgr/dao/AuthManagerDao.java
+2
-2
AuthManagerDaoImpl.java
.../beecode/inz/authmgr/internal/dao/AuthManagerDaoImpl.java
+16
-4
AuthManagerServiceImpl.java
.../inz/authmgr/internal/service/AuthManagerServiceImpl.java
+30
-2
DinasCommonController.java
...in/java/com/xyst/dinas/biz/web/DinasCommonController.java
+62
-0
No files found.
backend/inz.authmgr/src/main/java/com/beecode/inz/authmgr/common/AuthMgrConstants.java
View file @
a01aae81
...
...
@@ -71,6 +71,7 @@ public final class AuthMgrConstants {
String
PARAMETER_SEARCH
=
" staff.name like :staffName "
;
String
PARAMETER_user_enabled
=
" staff.user.enabled=:enabled "
;
String
PARAMETER_user_locked
=
" staff.user.locked=:locked "
;
String
PARAMETER_relation_department
=
" staff.department.paths like :relationDepartmentId "
;
}
}
backend/inz.authmgr/src/main/java/com/beecode/inz/authmgr/dao/AuthManagerDao.java
View file @
a01aae81
...
...
@@ -9,11 +9,11 @@ public interface AuthManagerDao {
List
<
StaffInfo
>
getEnabledStaffInfo
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Integer
pageNo
,
Integer
pageSize
,
Integer
locked
);
List
<
StaffInfo
>
getStaffInfo
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Integer
pageNo
,
Integer
pageSize
,
Integer
locked
,
Boolean
enabled
);
List
<
StaffInfo
>
getStaffInfo
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Integer
pageNo
,
Integer
pageSize
,
Integer
locked
,
Boolean
enabled
,
UUID
relationDepartmentId
);
Integer
getEnabledStaffCount
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
);
Integer
getStaffCount
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Boolean
enabled
);
Integer
getStaffCount
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Boolean
enabled
,
UUID
relationDepartmentId
);
}
backend/inz.authmgr/src/main/java/com/beecode/inz/authmgr/internal/dao/AuthManagerDaoImpl.java
View file @
a01aae81
...
...
@@ -22,11 +22,11 @@ public class AuthManagerDaoImpl implements AuthManagerDao {
@Override
public
List
<
StaffInfo
>
getEnabledStaffInfo
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Integer
pageNo
,
Integer
pageSize
,
Integer
locked
)
{
return
this
.
getStaffInfo
(
roleId
,
deptId
,
searchStr
,
pageNo
,
pageSize
,
locked
,
null
);
return
this
.
getStaffInfo
(
roleId
,
deptId
,
searchStr
,
pageNo
,
pageSize
,
locked
,
null
,
null
);
}
@Override
public
List
<
StaffInfo
>
getStaffInfo
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Integer
pageNo
,
Integer
pageSize
,
Integer
locked
,
Boolean
enabled
)
{
public
List
<
StaffInfo
>
getStaffInfo
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Integer
pageNo
,
Integer
pageSize
,
Integer
locked
,
Boolean
enabled
,
UUID
relationDepartmentId
)
{
return
template
.
execute
(
new
HibernateCallback
<
List
<
StaffInfo
>>(){
@Override
public
List
<
StaffInfo
>
doInHibernate
(
Session
session
)
throws
HibernateException
{
...
...
@@ -43,6 +43,9 @@ public class AuthManagerDaoImpl implements AuthManagerDao {
if
(
locked
!=
null
){
hql
+=
AuthMgrConstants
.
HQL
.
PARAMETER_user_locked
+
" and "
;
}
if
(
relationDepartmentId
!=
null
)
{
hql
+=
AuthMgrConstants
.
HQL
.
PARAMETER_relation_department
+
" and "
;
}
hql
+=
AuthMgrConstants
.
HQL
.
PARAMETER_user_enabled
;
// hql +=" 1=1 ";
Query
<
StaffInfo
>
query
=
session
.
createQuery
(
hql
,
StaffInfo
.
class
);
...
...
@@ -63,6 +66,9 @@ public class AuthManagerDaoImpl implements AuthManagerDao {
if
(
locked
!=
null
){
query
.
setParameter
(
"locked"
,
locked
==
1
?
false
:
true
);
}
if
(
relationDepartmentId
!=
null
)
{
query
.
setParameter
(
"relationDepartmentId"
,
"%"
+
relationDepartmentId
+
"%"
);
}
query
.
setFirstResult
((
pageNo
-
1
)*
pageSize
);
query
.
setMaxResults
(
pageSize
);
return
query
.
getResultList
();
...
...
@@ -73,11 +79,11 @@ public class AuthManagerDaoImpl implements AuthManagerDao {
@Override
public
Integer
getEnabledStaffCount
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
)
{
return
this
.
getStaffCount
(
roleId
,
deptId
,
searchStr
,
null
);
return
this
.
getStaffCount
(
roleId
,
deptId
,
searchStr
,
null
,
null
);
}
@Override
public
Integer
getStaffCount
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Boolean
enabled
)
{
public
Integer
getStaffCount
(
UUID
roleId
,
UUID
deptId
,
String
searchStr
,
Boolean
enabled
,
UUID
relationDepartmentId
)
{
return
template
.
execute
(
new
HibernateCallback
<
Integer
>(){
@Override
...
...
@@ -95,6 +101,9 @@ public class AuthManagerDaoImpl implements AuthManagerDao {
if
(
enabled
!=
null
)
{
hql
+=
AuthMgrConstants
.
HQL
.
PARAMETER_user_enabled
+
" and "
;
}
if
(
relationDepartmentId
!=
null
)
{
hql
+=
AuthMgrConstants
.
HQL
.
PARAMETER_relation_department
+
" and "
;
}
hql
+=
" 1=1 "
;
Query
<
Long
>
query
=
session
.
createQuery
(
hql
,
Long
.
class
);
...
...
@@ -110,6 +119,9 @@ public class AuthManagerDaoImpl implements AuthManagerDao {
if
(
enabled
!=
null
)
{
query
.
setParameter
(
"enabled"
,
enabled
);
}
if
(
relationDepartmentId
!=
null
)
{
query
.
setParameter
(
"relationDepartmentId"
,
"%"
+
relationDepartmentId
+
"%"
);
}
return
query
.
getSingleResult
().
intValue
();
}});
}
...
...
backend/inz.authmgr/src/main/java/com/beecode/inz/authmgr/internal/service/AuthManagerServiceImpl.java
View file @
a01aae81
...
...
@@ -5,12 +5,14 @@ import java.util.ArrayList;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
javax.transaction.Transactional
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisherAware
;
...
...
@@ -19,6 +21,7 @@ import org.springframework.util.Assert;
import
com.beecode.amino.core.Amino
;
import
com.beecode.bap.log.LogConstants
;
import
com.beecode.bap.log.service.LogService
;
import
com.beecode.bap.staff.BapContext
;
import
com.beecode.bap.staff.Staff
;
import
com.beecode.bap.staff.service.StaffService
;
import
com.beecode.bap2.common.license.LicenseProperty
;
...
...
@@ -36,6 +39,8 @@ import com.beecode.bcp.authz.service.RoleService;
import
com.beecode.bcp.group.service.GroupService
;
import
com.beecode.bcp.type.KClass
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.bcp.type.json.JSONObjectUtils
;
import
com.beecode.bcp.type.support.NullObject
;
import
com.beecode.inz.authmgr.common.AuthMgrConstants.RoleRootGroup
;
import
com.beecode.inz.authmgr.dao.AuthManagerDao
;
import
com.beecode.inz.authmgr.domain.Page
;
...
...
@@ -48,6 +53,9 @@ import com.jiuqi.np.tenant.Tenant;
import
com.jiuqi.np.tenant.spring.TenantRuntime
;
public
class
AuthManagerServiceImpl
implements
AuthManagerService
,
ApplicationEventPublisherAware
{
@Autowired
private
BapContext
bapContext
;
@Autowired
private
StaffService
staffService
;
...
...
@@ -219,10 +227,16 @@ public class AuthManagerServiceImpl implements AuthManagerService,ApplicationEve
if
(
pageSize
==
null
)
{
pageSize
=
Integer
.
MAX_VALUE
;
}
UUID
relationDepartmentId
=
this
.
getCurrentLoginRegionalCompanyRelationDepartmentId
();
Page
<
StaffInfo
>
page
=
new
Page
<>();
List
<
StaffInfo
>
staffInfos
=
authManagerDao
.
getStaffInfo
(
roleId
,
deptId
,
searchStr
,
pageNo
,
pageSize
,
locked
,
enabled
);
if
(
relationDepartmentId
==
null
)
{
page
.
setItemCount
(
0
);
page
.
setDatas
(
null
);
return
page
;
}
List
<
StaffInfo
>
staffInfos
=
authManagerDao
.
getStaffInfo
(
roleId
,
deptId
,
searchStr
,
pageNo
,
pageSize
,
locked
,
enabled
,
relationDepartmentId
);
page
.
setItemCount
(
authManagerDao
.
getStaffCount
(
roleId
,
deptId
,
searchStr
,
enabled
));
page
.
setItemCount
(
authManagerDao
.
getStaffCount
(
roleId
,
deptId
,
searchStr
,
enabled
,
relationDepartmentId
));
page
.
setPageNo
(
pageNo
);
page
.
setPageSize
(
pageSize
);
staffInfos
.
forEach
(
staff
->
staff
.
setRoles
(
getRoleByUser
(
staff
.
getUserId
())));
...
...
@@ -230,6 +244,20 @@ public class AuthManagerServiceImpl implements AuthManagerService,ApplicationEve
return
page
;
}
/**
* 获取当前登录的区域公司
* @return
*/
public
UUID
getCurrentLoginRegionalCompanyRelationDepartmentId
()
{
Map
<
String
,
String
>
map
=
bapContext
.
getCurrentUserDatas
();
String
currentRegionalCompany
=
map
.
get
(
"currentRegionalCompany"
);
JSONObject
param
=
new
JSONObject
(
currentRegionalCompany
);
if
(
param
.
isNull
(
"departmentId"
))
{
return
null
;
}
String
departmentId
=
param
.
getString
(
"departmentId"
);
return
UUID
.
fromString
(
departmentId
);
}
private
List
<
Role
>
getRoleByUser
(
UUID
userId
)
{
return
roleService
.
getByUser
(
userId
).
stream
()
...
...
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/web/DinasCommonController.java
View file @
a01aae81
...
...
@@ -2,7 +2,9 @@ package com.xyst.dinas.biz.web;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
org.json.JSONObject
;
...
...
@@ -17,6 +19,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.bind.annotation.RestController
;
import
com.beecode.bap.department.service.DepartmentService
;
import
com.beecode.bap.staff.Staff
;
import
com.beecode.bap.staff.service.StaffService
;
import
com.beecode.bap.staff.util.StaffUtil
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.inz.basis.team.pojo.ResponseObj
;
import
com.xyst.dinas.biz.enumeration.PlanningCycleEnum
;
...
...
@@ -29,6 +34,9 @@ public class DinasCommonController {
public
DepartmentService
departmentService
;
@Autowired
public
StaffService
staffService
;
@Autowired
public
PlanningCycleService
planningCycleService
;
/**
...
...
@@ -58,6 +66,60 @@ public class DinasCommonController {
return
list
;
}
/**
* @Description: 根据部门id查询该部门及其子部门的职员列表(包括该部门自身)
* @param id
* @return return_type
* @throws
*/
@ResponseBody
@RequestMapping
(
value
=
"/dinasBiz/staff/queryStaffByDepartmentId"
,
method
=
RequestMethod
.
POST
)
public
List
<
Map
<
String
,
Object
>>
queryStaffByDepartmentId
(
@RequestBody
String
body
)
{
JSONObject
param
=
new
JSONObject
(
body
);
List
<
Map
<
String
,
Object
>>
temp
=
new
ArrayList
<
Map
<
String
,
Object
>>();
if
(
param
.
isNull
(
"id"
))
{
return
null
;
}
String
departmentId
=
param
.
getString
(
"id"
);
Boolean
enable
=
param
.
getBoolean
(
"enable"
);
List
<
KObject
>
list
=
staffService
.
getAllByDept
(
UUID
.
fromString
(
departmentId
));
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
list
.
get
(
i
).
get
(
"user"
).
getBoolean
(
"enabled"
)
!=
enable
)
{
list
.
remove
(
i
);
}
}
for
(
KObject
item
:
list
)
{
temp
.
add
(
toMap
(
item
));
}
return
temp
;
}
private
Map
<
String
,
Object
>
toMap
(
KObject
staff
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
KObject
user
=
staff
.
get
(
Staff
.
USER
);
KObject
dept
=
staff
.
get
(
Staff
.
DEPARTMENT
);
map
.
put
(
Staff
.
ID
,
staff
.
getUuid
(
Staff
.
ID
));
map
.
put
(
Staff
.
CODE
,
staff
.
getString
(
Staff
.
CODE
));
map
.
put
(
Staff
.
NAME
,
staff
.
getString
(
Staff
.
NAME
));
map
.
put
(
Staff
.
SHORTNAME
,
staff
.
getString
(
Staff
.
SHORTNAME
));
map
.
put
(
Staff
.
SEX
,
staff
.
getInt
(
Staff
.
SEX
));
map
.
put
(
Staff
.
ENTRYTIME
,
StaffUtil
.
instantToLong
(
staff
.
getInstant
(
Staff
.
ENTRYTIME
)));
map
.
put
(
Staff
.
TELEPHONE
,
staff
.
getString
(
Staff
.
TELEPHONE
));
map
.
put
(
Staff
.
DUTY
,
staff
.
getString
(
Staff
.
DUTY
));
map
.
put
(
Staff
.
EMAIL
,
staff
.
getString
(
Staff
.
EMAIL
));
map
.
put
(
Staff
.
BIRTHDAY
,
StaffUtil
.
instantToLong
(
staff
.
getInstant
(
Staff
.
BIRTHDAY
)));
map
.
put
(
Staff
.
QQ
,
staff
.
getString
(
Staff
.
QQ
));
map
.
put
(
Staff
.
WECHAT
,
staff
.
getString
(
Staff
.
WECHAT
));
map
.
put
(
Staff
.
PORTRAIT
,
staff
.
getString
(
Staff
.
PORTRAIT
));
map
.
put
(
Staff
.
DEPARTMENTID
,
dept
.
getString
(
Staff
.
ID
));
map
.
put
(
Staff
.
DEPARTMENT
,
dept
.
getString
(
Staff
.
NAME
));
map
.
put
(
Staff
.
USERNAME
,
user
.
getString
(
Staff
.
USERNAME
));
map
.
put
(
Staff
.
CREATETIME
,
StaffUtil
.
instantToLong
(
staff
.
getInstant
(
Staff
.
ENTRYTIME
)));
map
.
put
(
Staff
.
LOCKED
,
user
.
getBoolean
(
Staff
.
LOCKED
));
map
.
put
(
Staff
.
ENABLED
,
user
.
getBoolean
(
Staff
.
ENABLED
));
return
map
;
}
@RequestMapping
(
"/planningCycle/init"
)
public
ResponseObj
initPlanningCycleData
()
{
planningCycleService
.
initData
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment