Commit 7ebdd490 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/develop' into develop

parents 41c91056 577c1cb3
......@@ -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.dapr.config.DaprUpmsProperties;
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.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
......@@ -70,6 +72,7 @@ public class TEmployeeInfoController {
// 缓存信息
private final CacheManager cacheManager;
private final MenuUtil menuUtil;
private final DaprUpmsProperties daprUpmsProperties;
......@@ -87,66 +90,10 @@ public class TEmployeeInfoController {
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
// 普通用户:
if (CommonConstants.ONE_STRING.equals(user.getSystemFlag())) {
// 菜单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));
}
}
if (Common.isEmpty(tEmployeeInfo.getMId())) {
tEmployeeInfo.setMId("1536922631616278529");
}
menuUtil.setAuthSql(user, tEmployeeInfo);
return R.ok(tEmployeeInfoService.getPage(page, tEmployeeInfo, null));
}
......
......@@ -493,7 +493,9 @@
from t_employee_info a
where a.DELETE_FLAG = '0'
<include refid="employeeInfo_where"/>
${sql}
<if test="tEmployeeInfo.authSql != null and tEmployeeInfo.authSql.trim() != ''">
${tEmployeeInfo.authSql}
</if>
order by a.CREATE_TIME desc
</select>
......
......@@ -12,7 +12,10 @@
<artifactId>yifu-common-dapr</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-upms-api</artifactId>
......
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);
}
}
}
}
}
}
......@@ -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.CheckDaprUtil,\
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
......@@ -70,4 +70,18 @@ public class BaseEntity implements Serializable {
@TableField(exist = false)
private String mId;
/**
* 是否关联部门表;0否;1是
*/
@TableField(exist = false)
@ExcelIgnore
private Integer isDept;
/**
* 权限sql
*/
@TableField(exist = false)
@ExcelIgnore
private String authSql;
}
......@@ -472,7 +472,7 @@
,'' fd_3adfee1ff1ca6a
,'' fd_3adfee203f86b2
,ifnull(a.ACTUAL_SALARY,'0') fd_3adfee20fe5ba4
,'' fd_3adfee21802434
,ifnull(a.RELAY_SALARY,'0') - ifnull(ifnull(withholidingPersonSocial.SALARY_MONEY,personalSocial.SALARY_MONEY),'0') - ifnull(ifnull(withholidingPersonFund.SALARY_MONEY,personalFund.SALARY_MONEY),'') fd_3adfee21802434
,'' fd_3adfee4ba5ad36
,'' fd_3adfee4c0c59ee
,'' fd_3adfee5dd14866
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment