Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
aa00cf96
Commit
aa00cf96
authored
May 16, 2022
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建人
parent
3228826c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
169 additions
and
0 deletions
+169
-0
CreatorUtils.java
...in/java/com/gic/haoban/manage/web/utils/CreatorUtils.java
+169
-0
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/utils/CreatorUtils.java
0 → 100644
View file @
aa00cf96
package
com
.
gic
.
haoban
.
manage
.
web
.
utils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.gic.clerk.api.service.ClerkMoveService
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.enterprise.api.dto.EnterpriseSettingDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
/**
*
* @ClassName: CreatorUtils
* @Description: 商户后端管理员权限
* @author xugh
* @date 2019年10月14日 下午12:48:29
*
*/
@Component
public
class
CreatorUtils
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
CreatorUtils
.
class
);
public
static
String
tip
=
"非创建人不允许此操作"
;
private
static
EnterpriseService
enterpriseService
;
private
static
ClerkService
clerkService
;
private
static
ClerkMoveService
clerkMoveService
;
@Autowired
public
void
setEnterpriseService
(
EnterpriseService
enterpriseService
)
{
CreatorUtils
.
enterpriseService
=
enterpriseService
;
}
@Autowired
public
void
setClerkService
(
ClerkService
clerkService
)
{
CreatorUtils
.
clerkService
=
clerkService
;
}
@Autowired
public
void
setClerkMoveService
(
ClerkMoveService
clerkMoveService
)
{
CreatorUtils
.
clerkMoveService
=
clerkMoveService
;
}
public
static
int
getDepartmentRights
()
{
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
Integer
departmemntRights
=
loginUser
.
getDepartAuth
();
if
(
departmemntRights
==
null
)
{
departmemntRights
=
3
;
}
return
departmemntRights
;
}
/**
*
* @Title: getShowClickList
* @Description: 获取权限范围的管理员ID集合
* @author xugh
* @return
* @throws
*/
public
static
List
<
String
>
getCreatorIdList
(
int
showSelfFlag
)
{
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
clerkId
=
loginUser
.
getClerkId
();
List
<
String
>
userList
=
getList
(
clerkId
);
if
(
showSelfFlag
==
1
)
{
List
<
String
>
creatorIdList
=
new
ArrayList
<>();
creatorIdList
.
add
(
clerkId
);
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
creatorIdList
.
addAll
(
userList
);
}
return
creatorIdList
;
}
EnterpriseSettingDTO
enterpriseSetting
=
enterpriseService
.
getEnterpriseSettingByEnterpriseId
(
loginUser
.
getEnterpriseId
());
if
(!(
enterpriseSetting
.
getEnableAccessControl
()
!=
null
&&
enterpriseSetting
.
getEnableAccessControl
()
==
1
))
{
logger
.
info
(
"权限控制-未启用"
);
return
null
;
}
// 判断是否超级管理员
if
(
loginUser
.
getSuperAdmin
()
==
1
)
{
logger
.
info
(
"权限控制-超级管理员"
);
return
null
;
}
// 部门权限范围 1可见本人 2可见部分 3可见所有
Integer
departmemntRights
=
loginUser
.
getDepartAuth
();
if
(
departmemntRights
==
null
)
{
departmemntRights
=
3
;
}
logger
.
info
(
"权限控制-可见{}"
,
departmemntRights
);
if
(
departmemntRights
==
3
)
{
logger
.
info
(
"权限控制-可见所有"
);
return
null
;
}
List
<
String
>
creatorIdList
=
new
ArrayList
<>();
if
(
departmemntRights
==
1
)
{
creatorIdList
.
add
(
clerkId
);
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
creatorIdList
.
addAll
(
userList
);
}
}
if
(
departmemntRights
==
2
)
{
creatorIdList
.
add
(
clerkId
);
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
creatorIdList
.
addAll
(
userList
);
}
List
<
String
>
departClerIdList
=
clerkService
.
listClerkIdsInSameDeptByClerkId
(
clerkId
);
if
(
CollectionUtils
.
isNotEmpty
(
departClerIdList
))
{
creatorIdList
.
addAll
(
departClerIdList
);
List
<
String
>
list
=
clerkMoveService
.
clerkList
(
departClerIdList
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
creatorIdList
.
addAll
(
list
);
}
}
}
logger
.
info
(
"权限控制,返回创建人creatorIdList={}"
,
creatorIdList
);
return
creatorIdList
;
}
public
static
boolean
isAdmin
()
{
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
if
(
loginUser
.
getSuperAdmin
()
==
1
)
{
return
true
;
}
return
false
;
}
public
static
boolean
showSelfParam
()
{
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
String
enterpriseId
=
loginUser
.
getEnterpriseId
();
EnterpriseSettingDTO
enterpriseSetting
=
enterpriseService
.
getEnterpriseSettingByEnterpriseId
(
enterpriseId
);
if
(!(
enterpriseSetting
.
getEnableAccessControl
()
!=
null
&&
enterpriseSetting
.
getEnableAccessControl
()
==
1
))
{
return
false
;
}
Integer
departmemntRights
=
loginUser
.
getDepartAuth
();
if
(
departmemntRights
==
null
)
{
departmemntRights
=
3
;
}
if
(
departmemntRights
==
1
)
{
return
false
;
}
return
true
;
}
public
static
boolean
openFlag
()
{
WebLoginDTO
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
EnterpriseSettingDTO
enterpriseSetting
=
enterpriseService
.
getEnterpriseSettingByEnterpriseId
(
loginUser
.
getEnterpriseId
());
if
(!(
enterpriseSetting
.
getEnableAccessControl
()
!=
null
&&
enterpriseSetting
.
getEnableAccessControl
()
==
1
))
{
return
false
;
}
return
true
;
}
public
static
List
<
String
>
getList
(
String
userId
)
{
List
<
String
>
authorizationClerkIdList
=
clerkMoveService
.
clerkList
(
userId
);
logger
.
info
(
"查询关联id={},{}"
,
userId
,
authorizationClerkIdList
);
return
authorizationClerkIdList
;
}
}
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