Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rop-dj-pe-analysis
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4dead4da
authored
Dec 11, 2025
by
蔡茜
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
校验角色
1 parent
059625fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
16 deletions
src/main/java/cn/com/glsx/dj/controller/BusinessAnalysisController.java
src/main/java/cn/com/glsx/dj/util/CommonUtil.java
src/main/java/cn/com/glsx/dj/controller/BusinessAnalysisController.java
View file @
4dead4d
package
cn
.
com
.
glsx
.
dj
.
controller
;
import
cn.com.glsx.dj.enums.LoginRoleEnum
;
import
cn.com.glsx.dj.enums.RopErrorEnum
;
import
cn.com.glsx.dj.peanalysis.dto.req.output.TotalOutputReq
;
import
cn.com.glsx.dj.peanalysis.dto.res.output.*
;
import
cn.com.glsx.dj.peanalysis.remote.BusinessAnalysisRemote
;
import
cn.com.glsx.dj.request.output.*
;
import
cn.com.glsx.dj.response.LoginUserInfoResponse
;
import
cn.com.glsx.dj.util.CommonUtil
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.rop.response.RopResponse
;
...
...
@@ -31,16 +28,12 @@ public class BusinessAnalysisController {
@ApiOperation
(
"总部视角----全业务-总产值、门店总数"
)
@ServiceMethod
(
method
=
"dj.api.smartcarlife.business.analysis.output.total"
,
needInSession
=
NeedInSessionType
.
NO
)
public
RopResponse
<
TotalOutputResponse
>
totalOutput
(
TotalOutputRequest
request
)
{
LoginUserInfoResponse
loginUserInfo
=
CommonUtil
.
getLoginUserInfo
();
if
(
loginUserInfo
==
null
)
{
log
.
info
(
"登录失效"
);
return
RopResponse
.
result
(
RopErrorEnum
.
GET_LOGIN_EXPIRE
);
}
log
.
info
(
"totalOutput params: {},loginRole:{}"
,
request
,
loginUserInfo
.
getLoginRole
());
if
(
loginUserInfo
.
getLoginRole
()
==
null
||
loginUserInfo
.
getLoginRole
()
==
LoginRoleEnum
.
NONE
.
getValue
())
{
return
RopResponse
.
error
(
"您暂无使用权限,请确认后重新操作。"
);
boolean
b
=
CommonUtil
.
validLeadRole
();
if
(!
b
)
{
RopResponse
.
error
(
"您暂无使用权限,请确认后重新操作。"
);
}
TotalOutputReq
req
=
CommonUtil
.
convertRequest
(
TotalOutputReq
.
class
);
log
.
info
(
"totalOutput request: {},req:{}"
,
request
,
req
);
RpcResponse
<
TotalOutputResponse
>
response
=
businessAnalysisRemote
.
totalOutput
(
req
);
return
CommonUtil
.
convertRopResponse
(
response
);
}
...
...
src/main/java/cn/com/glsx/dj/util/CommonUtil.java
View file @
4dead4d
package
cn
.
com
.
glsx
.
dj
.
util
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
cn.com.glsx.dj.enums.LoginRoleEnum
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -216,4 +213,39 @@ public class CommonUtil {
public
void
setLoginService
(
LoginService
loginService
)
{
CommonUtil
.
loginService
=
loginService
;
}
private
static
final
Set
<
Integer
>
LEAD_ROLES
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
LoginRoleEnum
.
OTHER
.
getValue
(),
LoginRoleEnum
.
AREA_SUPERVISION_LEADER
.
getValue
(),
LoginRoleEnum
.
SALE_LEADER
.
getValue
()
)));
private
static
final
Set
<
Integer
>
SIMPLE_ROLES
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
LoginRoleEnum
.
AREA_SUPERVISION
.
getValue
(),
LoginRoleEnum
.
SELE
.
getValue
(),
LoginRoleEnum
.
FLIGHT_SUPERVISION
.
getValue
(),
LoginRoleEnum
.
ONLINE_SUPERVISION
.
getValue
()
)));
private
static
boolean
checkRole
(
Set
<
Integer
>
allowedRoles
)
{
LoginUserInfoResponse
loginUserInfo
=
CommonUtil
.
getLoginUserInfo
();
if
(
loginUserInfo
==
null
)
{
log
.
info
(
"loginUserInfo is null"
);
return
false
;
}
Integer
loginRole
=
loginUserInfo
.
getLoginRole
();
log
.
info
(
"loginUserInfo:{}"
,
loginUserInfo
);
if
(
loginRole
==
null
||
loginRole
==
LoginRoleEnum
.
NONE
.
getValue
())
{
return
false
;
}
return
allowedRoles
.
contains
(
loginRole
);
}
public
static
boolean
validLeadRole
()
{
return
checkRole
(
LEAD_ROLES
);
}
public
static
boolean
validSimpleRole
()
{
return
checkRole
(
SIMPLE_ROLES
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment