Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
fangxinjiang
yifu-mvp
Commits
0353de82
Commit
0353de82
authored
Sep 13, 2022
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
菜单权限1
parent
84e2e3e3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
61 deletions
+124
-61
TEmployeeInfoController.java
.../v1/yifu/archives/controller/TEmployeeInfoController.java
+6
-59
TEmployeeInfoMapper.xml
...ves-biz/src/main/resources/mapper/TEmployeeInfoMapper.xml
+3
-1
pom.xml
yifu-common/yifu-common-dapr/pom.xml
+4
-1
MenuUtil.java
...om/yifu/cloud/plus/v1/yifu/common/dapr/util/MenuUtil.java
+96
-0
spring.factories
...-common-dapr/src/main/resources/META-INF/spring.factories
+1
-0
BaseEntity.java
...fu.cloud.plus.v1/yifu/common/mybatis/base/BaseEntity.java
+14
-0
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/controller/TEmployeeInfoController.java
View file @
0353de82
...
@@ -32,7 +32,9 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
...
@@ -32,7 +32,9 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner
;
import
com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
...
@@ -70,6 +72,7 @@ public class TEmployeeInfoController {
...
@@ -70,6 +72,7 @@ public class TEmployeeInfoController {
// 缓存信息
// 缓存信息
private
final
CacheManager
cacheManager
;
private
final
CacheManager
cacheManager
;
private
final
MenuUtil
menuUtil
;
private
final
DaprUpmsProperties
daprUpmsProperties
;
private
final
DaprUpmsProperties
daprUpmsProperties
;
...
@@ -87,66 +90,10 @@ public class TEmployeeInfoController {
...
@@ -87,66 +90,10 @@ public class TEmployeeInfoController {
if
(
user
==
null
||
Common
.
isEmpty
(
user
.
getId
()))
{
if
(
user
==
null
||
Common
.
isEmpty
(
user
.
getId
()))
{
return
R
.
failed
(
CommonConstants
.
PLEASE_LOG_IN
);
return
R
.
failed
(
CommonConstants
.
PLEASE_LOG_IN
);
}
}
// 普通用户:
if
(
Common
.
isEmpty
(
tEmployeeInfo
.
getMId
()))
{
if
(
CommonConstants
.
ONE_STRING
.
equals
(
user
.
getSystemFlag
()))
{
tEmployeeInfo
.
setMId
(
"1536922631616278529"
);
// 菜单id
String
menuId
=
"1536922631616278529"
;
String
linkId
=
user
.
getId
();
int
linkType
=
1
;
// 用户
SysDataAuth
sysDataAuth
=
new
SysDataAuth
();
sysDataAuth
.
setLinkId
(
linkId
);
sysDataAuth
.
setLinkType
(
linkType
);
// 获取缓存菜单权限的步骤:
Cache
cache
=
cacheManager
.
getCache
(
CacheConstants
.
DATA_AUTH_DETAILS
+
linkType
);
Object
obj
=
null
;
if
(
cache
!=
null
)
{
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
if
(
Common
.
isEmpty
(
obj
))
{
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
()
,
"/dataAuth/refreshAuth"
,
sysDataAuth
,
TEmployeeInfo
.
class
,
SecurityConstants
.
FROM_IN
);
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
if
(
Common
.
isEmpty
(
obj
))
{
linkId
=
user
.
getUserGroup
();
linkType
=
0
;
// 用户组
cache
=
cacheManager
.
getCache
(
CacheConstants
.
DATA_AUTH_DETAILS
+
linkType
);
if
(
cache
!=
null
)
{
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
if
(
Common
.
isEmpty
(
obj
))
{
sysDataAuth
.
setLinkId
(
linkId
);
sysDataAuth
.
setLinkType
(
linkType
);
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
()
,
"/dataAuth/refreshAuth"
,
sysDataAuth
,
TEmployeeInfo
.
class
,
SecurityConstants
.
FROM_IN
);
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
}
}
}
}
}
if
(
Common
.
isNotNull
(
obj
))
{
SimpleValueWrapper
objs
=
(
SimpleValueWrapper
)
obj
;
if
(
objs
!=
null
)
{
String
sql
=
String
.
valueOf
(
objs
.
get
());
if
(
sql
.
contains
(
"#deptId"
))
{
// TODO - 需要关联部门表
}
if
(
sql
.
contains
(
"#create_by"
))
{
sql
=
sql
.
replace
(
"#create_by"
,
user
.
getId
());
}
if
(
sql
.
contains
(
"#settleDomainId"
))
{
// TODO - 获取人员项目权限
// sql = sql.replace("#settleDomainId", ",'1','2' ")
sql
=
sql
.
replace
(
"or a.settle_domain_id in ('0'#settleDomainId) "
,
""
);
}
if
(
sql
.
contains
(
"#deptId"
))
{
// TODO - 获取人员部门权限
// sql = sql.replace("#settleDomainId", ",'1','2' ")
sql
=
sql
.
replace
(
" or dept.dept_id = #deptId "
,
""
);
}
return
R
.
ok
(
tEmployeeInfoService
.
getPage
(
page
,
tEmployeeInfo
,
sql
));
}
}
}
}
menuUtil
.
setAuthSql
(
user
,
tEmployeeInfo
);
return
R
.
ok
(
tEmployeeInfoService
.
getPage
(
page
,
tEmployeeInfo
,
null
));
return
R
.
ok
(
tEmployeeInfoService
.
getPage
(
page
,
tEmployeeInfo
,
null
));
}
}
...
...
yifu-archives/yifu-archives-biz/src/main/resources/mapper/TEmployeeInfoMapper.xml
View file @
0353de82
...
@@ -493,7 +493,9 @@
...
@@ -493,7 +493,9 @@
from t_employee_info a
from t_employee_info a
where a.DELETE_FLAG = '0'
where a.DELETE_FLAG = '0'
<include
refid=
"employeeInfo_where"
/>
<include
refid=
"employeeInfo_where"
/>
${sql}
<if
test=
"tEmployeeInfo.authSql != null and tEmployeeInfo.authSql.trim() != ''"
>
${tEmployeeInfo.authSql}
</if>
order by a.CREATE_TIME desc
order by a.CREATE_TIME desc
</select>
</select>
...
...
yifu-common/yifu-common-dapr/pom.xml
View file @
0353de82
...
@@ -12,7 +12,10 @@
...
@@ -12,7 +12,10 @@
<artifactId>
yifu-common-dapr
</artifactId>
<artifactId>
yifu-common-dapr
</artifactId>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<dependencies>
<dependencies>
<dependency>
<groupId>
com.yifu.cloud.plus.v1
</groupId>
<artifactId>
yifu-common-mybatis
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
com.yifu.cloud.plus.v1
</groupId>
<groupId>
com.yifu.cloud.plus.v1
</groupId>
<artifactId>
yifu-upms-api
</artifactId>
<artifactId>
yifu-upms-api
</artifactId>
...
...
yifu-common/yifu-common-dapr/src/main/java/com/yifu/cloud/plus/v1/yifu/common/dapr/util/MenuUtil.java
0 → 100644
View file @
0353de82
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
dapr
.
util
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDataAuth
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.support.SimpleValueWrapper
;
/**
* @author hgw
* 2022-9-13 16:14:34
* @Description 公共获取菜单权限的工具
*/
@EnableConfigurationProperties
({
DaprUpmsProperties
.
class
})
@RequiredArgsConstructor
@Slf4j
public
class
MenuUtil
{
// 缓存信息
private
final
CacheManager
cacheManager
;
private
final
DaprUpmsProperties
daprUpmsProperties
;
private
final
String
DEPT
=
"#deptId"
;
public
void
setAuthSql
(
YifuUser
user
,
BaseEntity
entity
)
{
// 普通用户:
if
(
CommonConstants
.
ONE_STRING
.
equals
(
user
.
getSystemFlag
()))
{
// 菜单id
String
menuId
=
entity
.
getMId
();
if
(
Common
.
isNotNull
(
menuId
))
{
String
linkId
=
user
.
getId
();
int
linkType
=
1
;
// 用户
SysDataAuth
sysDataAuth
=
new
SysDataAuth
();
sysDataAuth
.
setLinkId
(
linkId
);
sysDataAuth
.
setLinkType
(
linkType
);
// 获取缓存菜单权限的步骤:
Cache
cache
=
cacheManager
.
getCache
(
CacheConstants
.
DATA_AUTH_DETAILS
+
linkType
);
Object
obj
=
null
;
if
(
cache
!=
null
)
{
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
if
(
Common
.
isEmpty
(
obj
))
{
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
()
,
"/dataAuth/refreshAuth"
,
sysDataAuth
,
SysDataAuth
.
class
,
SecurityConstants
.
FROM_IN
);
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
if
(
Common
.
isEmpty
(
obj
))
{
linkId
=
user
.
getUserGroup
();
linkType
=
0
;
// 用户组
cache
=
cacheManager
.
getCache
(
CacheConstants
.
DATA_AUTH_DETAILS
+
linkType
);
if
(
cache
!=
null
)
{
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
if
(
Common
.
isEmpty
(
obj
))
{
sysDataAuth
.
setLinkId
(
linkId
);
sysDataAuth
.
setLinkType
(
linkType
);
HttpDaprUtil
.
invokeMethodPost
(
daprUpmsProperties
.
getAppUrl
(),
daprUpmsProperties
.
getAppId
()
,
"/dataAuth/refreshAuth"
,
sysDataAuth
,
SysDataAuth
.
class
,
SecurityConstants
.
FROM_IN
);
obj
=
cache
.
get
(
linkId
+
CommonConstants
.
DOWN_LINE_STRING
+
menuId
);
}
}
}
}
}
if
(
Common
.
isNotNull
(
obj
))
{
SimpleValueWrapper
objs
=
(
SimpleValueWrapper
)
obj
;
if
(
objs
!=
null
)
{
String
sql
=
String
.
valueOf
(
objs
.
get
());
if
(
sql
.
contains
(
DEPT
))
{
entity
.
setIsDept
(
CommonConstants
.
ONE_INT
);
}
if
(
sql
.
contains
(
"#create_by"
))
{
sql
=
sql
.
replace
(
"#create_by"
,
user
.
getId
());
}
if
(
sql
.
contains
(
"#settleDomainId"
))
{
// TODO - 获取人员项目权限
// sql = sql.replace("#settleDomainId", ",'1','2' ")
sql
=
sql
.
replace
(
"or a.settle_domain_id in ('0'#settleDomainId) "
,
""
);
}
if
(
sql
.
contains
(
DEPT
))
{
sql
=
sql
.
replace
(
DEPT
,
String
.
valueOf
(
user
.
getDeptId
()));
//sql = sql.replace(" or dept.dept_id = #deptId ", "")
}
entity
.
setAuthSql
(
sql
);
}
}
}
}
}
}
yifu-common/yifu-common-dapr/src/main/resources/META-INF/spring.factories
View file @
0353de82
...
@@ -3,4 +3,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
...
@@ -3,4 +3,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.CheckDaprUtil,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.CheckDaprUtil,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.SocialDaprUtils,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.SocialDaprUtils,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.SalaryDaprUtil
com.yifu.cloud.plus.v1.yifu.common.dapr.util.SalaryDaprUtil
yifu-common/yifu-common-mybatis/src/main/java/com/yifu.cloud.plus.v1/yifu/common/mybatis/base/BaseEntity.java
View file @
0353de82
...
@@ -70,4 +70,18 @@ public class BaseEntity implements Serializable {
...
@@ -70,4 +70,18 @@ public class BaseEntity implements Serializable {
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
String
mId
;
private
String
mId
;
/**
* 是否关联部门表;0否;1是
*/
@TableField
(
exist
=
false
)
@ExcelIgnore
private
Integer
isDept
;
/**
* 权限sql
*/
@TableField
(
exist
=
false
)
@ExcelIgnore
private
String
authSql
;
}
}
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