♻️ 重构代码,图形化数据权限、合并模块
This commit is contained in:
1 parent
1fe7703246
commit
492b38742d
45 files changed
+336
-359
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ pigx
|
||||
├── pigx-auth -- 授权服务提供[3000]
|
||||
├── pigx-common -- 系统公共模块
|
||||
├ ├── pigx-common-core -- 公共工具类核心包
|
||||
├ ├── pigx-common-cache -- 缓存
|
||||
├ ├── pigx-common-data -- 数据相关
|
||||
├ ├── pigx-common-job -- 定时任务
|
||||
├ ├── pigx-common-log -- 日志服务
|
||||
├ └── pigx-common-security -- 安全工具类
|
||||
|
||||
+12
-12
@@ -50,6 +50,18 @@
|
||||
<artifactId>pigx-common-security</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--mysql 驱动-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.connector.version}</version>
|
||||
</dependency>
|
||||
<!--缓存操作-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-data</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--JDBC相关-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -60,12 +72,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
</dependency>
|
||||
<!--缓存操作相关-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--spring security 、oauth、jwt依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
@@ -83,12 +89,6 @@
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
<version>${security.oauth.version}</version>
|
||||
</dependency>
|
||||
<!--数据库-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.connector.version}</version>
|
||||
</dependency>
|
||||
<!--web 模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.security.service.PigxUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -120,15 +120,10 @@ public class PigxTokenEndpoint {
|
||||
* 查询token
|
||||
*
|
||||
* @param params 分页参数
|
||||
* @param from 标志
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/page")
|
||||
public R<Page> tokenList(@RequestBody Map<String, Object> params, @RequestHeader(required = false) String from) {
|
||||
if (StrUtil.isBlank(from)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public R<Page> tokenList(@RequestBody Map<String, Object> params) {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
//根据分页参数获取对应数据
|
||||
List<String> pages = findKeysForPage(PIGX_OAUTH_ACCESS + "*", MapUtil.getInt(params, PaginationConstants.CURRENT), MapUtil.getInt(params, PaginationConstants.SIZE));
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.pig4cloud.pigx.common.cache.RedisTemplateConfig,\
|
||||
com.pig4cloud.pigx.common.cache.RedisCacheManagerConfig,\
|
||||
com.pig4cloud.pigx.common.cache.RedisCacheAutoConfiguration
|
||||
|
||||
@@ -50,12 +50,6 @@
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<!--mybatis plus extension,包含了mybatis plus core-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<!--feign 依赖-->
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
|
||||
@@ -27,19 +27,31 @@
|
||||
<version>2.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<artifactId>pigx-common-data</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>pigx 缓存工具类</description>
|
||||
<description>pigx 数据操作相关</description>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!--工具类核心包 要从线程中获取租户ID-->
|
||||
<!--工具类核心包-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--mybatis plus extension,包含了mybatis plus core-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<!--安全依赖获取上下文信息-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-security</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--缓存依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.cache;
|
||||
package com.pig4cloud.pigx.common.data.cache;
|
||||
|
||||
import org.springframework.dao.PessimisticLockingFailureException;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
+2
-2
@@ -15,10 +15,10 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.cache;
|
||||
package com.pig4cloud.pigx.common.data.cache;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.cache;
|
||||
package com.pig4cloud.pigx.common.data.cache;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.cache;
|
||||
package com.pig4cloud.pigx.common.data.cache;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.cache;
|
||||
package com.pig4cloud.pigx.common.data.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
+3
-2
@@ -15,11 +15,12 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.core.datascope;
|
||||
package com.pig4cloud.pigx.common.data.datascope;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class DataScope extends HashMap {
|
||||
/**
|
||||
* 具体的数据范围
|
||||
*/
|
||||
private List<Integer> deptIds;
|
||||
private List<Integer> deptIds = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 是否只查询本部门
|
||||
+66
-17
@@ -15,12 +15,20 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.core.datascope;
|
||||
package com.pig4cloud.pigx.common.data.datascope;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
||||
import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.exception.CheckedException;
|
||||
import com.pig4cloud.pigx.common.data.enums.DataScopeTypeEnum;
|
||||
import com.pig4cloud.pigx.common.security.service.PigxUser;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.executor.statement.StatementHandler;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
@@ -29,26 +37,29 @@ import org.apache.ibatis.mapping.SqlCommandType;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.reflection.SystemMetaObject;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/8/30
|
||||
* @date 2018/12/26
|
||||
* <p>
|
||||
* mybatis 数据权限拦截器
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
|
||||
public class DataScopeInterceptor extends AbstractSqlParserHandler implements Interceptor {
|
||||
private final DataSource dataSource;
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
|
||||
StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget());
|
||||
MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
|
||||
this.sqlParser(metaObject);
|
||||
// 先判断是不是SELECT操作
|
||||
@@ -63,19 +74,57 @@ public class DataScopeInterceptor extends AbstractSqlParserHandler implements In
|
||||
|
||||
//查找参数中包含DataScope类型的参数
|
||||
DataScope dataScope = findDataScopeObject(parameterObject);
|
||||
|
||||
if (dataScope == null) {
|
||||
return invocation.proceed();
|
||||
} else {
|
||||
String scopeName = dataScope.getScopeName();
|
||||
List<Integer> deptIds = dataScope.getDeptIds();
|
||||
if (StrUtil.isNotBlank(scopeName) && CollectionUtil.isNotEmpty(deptIds)) {
|
||||
String join = CollectionUtil.join(deptIds, ",");
|
||||
originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")";
|
||||
metaObject.setValue("delegate.boundSql.sql", originalSql);
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
String scopeName = dataScope.getScopeName();
|
||||
List<Integer> deptIds = dataScope.getDeptIds();
|
||||
// 优先获取赋值数据
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
if (user == null) {
|
||||
throw new CheckedException("auto datascope, set up security details true");
|
||||
}
|
||||
|
||||
List<String> roleIdList = user.getAuthorities()
|
||||
.stream().map(GrantedAuthority::getAuthority)
|
||||
.filter(authority -> authority.startsWith(SecurityConstants.ROLE))
|
||||
.map(authority -> authority.split("_")[1])
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Entity query = Db.use(dataSource)
|
||||
.query("SELECT * FROM sys_role where role_id IN (" + CollUtil.join(roleIdList, ",") + ")")
|
||||
.stream().min(Comparator.comparingInt(o -> o.getInt("ds_type"))).get();
|
||||
|
||||
Integer dsType = query.getInt("ds_type");
|
||||
// 查询全部
|
||||
if (DataScopeTypeEnum.ALL.getType() == dsType) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
// 自定义
|
||||
if (DataScopeTypeEnum.CUSTOM.getType() == dsType) {
|
||||
String dsScope = query.getStr("ds_scope");
|
||||
deptIds.addAll(Arrays.stream(dsScope.split(","))
|
||||
.map(Integer::parseInt).collect(Collectors.toList()));
|
||||
}
|
||||
// 查询本级及其下级
|
||||
if (DataScopeTypeEnum.OWN_CHILD_LEVEL.getType() == dsType) {
|
||||
List<Integer> deptIdList = Db.use(dataSource)
|
||||
.findBy("sys_dept_relation", "ancestor", user.getDeptId())
|
||||
.stream().map(entity -> entity.getInt("descendant"))
|
||||
.collect(Collectors.toList());
|
||||
deptIds.addAll(deptIdList);
|
||||
}
|
||||
// 只查询本级
|
||||
if (DataScopeTypeEnum.OWN_LEVEL.getType() == dsType) {
|
||||
deptIds.add(user.getDeptId());
|
||||
}
|
||||
}
|
||||
String join = CollectionUtil.join(deptIds, ",");
|
||||
originalSql = "select * from (" + originalSql + ") temp_data_scope where temp_data_scope." + scopeName + " in (" + join + ")";
|
||||
metaObject.setValue("delegate.boundSql.sql", originalSql);
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
/**
|
||||
+32
-25
@@ -15,39 +15,46 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.daemon.config;
|
||||
package com.pig4cloud.pigx.common.data.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/29
|
||||
* @date 2018/12/26
|
||||
* <p>
|
||||
* 数据权限类型
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan("com.pig4cloud.pigx.daemon.mapper")
|
||||
public class MybatisPlusConfigurer {
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DataScopeTypeEnum {
|
||||
/**
|
||||
* 分页插件
|
||||
*
|
||||
* @return PaginationInterceptor
|
||||
* 查询全部数据
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
ALL(0, "全部"),
|
||||
|
||||
/**
|
||||
* 逻辑删除插件
|
||||
*
|
||||
* @return LogicSqlInjector
|
||||
* 自定义
|
||||
*/
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new LogicSqlInjector();
|
||||
}
|
||||
CUSTOM(1, "自定义"),
|
||||
|
||||
/**
|
||||
* 本级及子级
|
||||
*/
|
||||
OWN_CHILD_LEVEL(2, "本级及子级"),
|
||||
|
||||
/**
|
||||
* 本级
|
||||
*/
|
||||
OWN_LEVEL(3, "本级");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final int type;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
}
|
||||
+20
-29
@@ -15,34 +15,31 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.act.config;
|
||||
package com.pig4cloud.pigx.common.data.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.core.parser.ISqlParser;
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
import com.pig4cloud.pigx.common.data.datascope.DataScopeInterceptor;
|
||||
import com.pig4cloud.pigx.common.data.tenant.PigxTenantHandler;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/9/27
|
||||
* mybatis-plus 配置
|
||||
* @date 2017/10/29
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@MapperScan("com.pig4cloud.pigx.act.mapper")
|
||||
public class MybatisPlusConfigurer {
|
||||
@MapperScan("com.pig4cloud.pigx.*.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*
|
||||
@@ -53,29 +50,23 @@ public class MybatisPlusConfigurer {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
TenantSqlParser tenantSqlParser = new TenantSqlParser();
|
||||
tenantSqlParser.setTenantHandler(new TenantHandler() {
|
||||
@Override
|
||||
public Expression getTenantId() {
|
||||
Integer tenantId = TenantContextHolder.getTenantId();
|
||||
log.debug("当前租户为 >> {}", tenantId);
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenantIdColumn() {
|
||||
return "tenant_id";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTableFilter(String tableName) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
tenantSqlParser.setTenantHandler(new PigxTenantHandler());
|
||||
sqlParserList.add(tenantSqlParser);
|
||||
paginationInterceptor.setSqlParserList(sqlParserList);
|
||||
return paginationInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据权限插件
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return DataScopeInterceptor
|
||||
*/
|
||||
@Bean
|
||||
public DataScopeInterceptor dataScopeInterceptor(DataSource dataSource) {
|
||||
return new DataScopeInterceptor(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除插件
|
||||
*
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.security.feign;
|
||||
package com.pig4cloud.pigx.common.data.tenant;
|
||||
|
||||
import feign.RequestInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
+1
-2
@@ -15,10 +15,9 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.security.feign;
|
||||
package com.pig4cloud.pigx.common.data.tenant;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.data.tenant;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018-12-26
|
||||
* <p>
|
||||
* 租户维护处理器
|
||||
*/
|
||||
@Slf4j
|
||||
public class PigxTenantHandler implements TenantHandler {
|
||||
private static final String[] TENANT_TABLES = new String[]{"sys_user", "sys_role", "sys_dept",
|
||||
"sys_log", "sys_social_details", "sys_dict", "sys_log", "oa_leave_bill"};
|
||||
|
||||
/**
|
||||
* 获取租户值
|
||||
*
|
||||
* @return 租户值
|
||||
*/
|
||||
@Override
|
||||
public Expression getTenantId() {
|
||||
Integer tenantId = TenantContextHolder.getTenantId();
|
||||
log.debug("当前租户为 >> {}", tenantId);
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户字段名
|
||||
*
|
||||
* @return 租户字段名
|
||||
*/
|
||||
@Override
|
||||
public String getTenantIdColumn() {
|
||||
return "tenant_id";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名判断是否进行过滤
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return 是否进行过滤
|
||||
*/
|
||||
@Override
|
||||
public boolean doTableFilter(String tableName) {
|
||||
return !ArrayUtil.contains(TENANT_TABLES, tableName);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.core.util;
|
||||
package com.pig4cloud.pigx.common.data.tenant;
|
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import lombok.experimental.UtilityClass;
|
||||
+1
-2
@@ -15,11 +15,10 @@
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.common.security.filter;
|
||||
package com.pig4cloud.pigx.common.data.tenant;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -0,0 +1,7 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.pig4cloud.pigx.common.data.cache.RedisTemplateConfig,\
|
||||
com.pig4cloud.pigx.common.data.cache.RedisCacheManagerConfig,\
|
||||
com.pig4cloud.pigx.common.data.cache.RedisCacheAutoConfiguration,\
|
||||
com.pig4cloud.pigx.common.data.tenant.TenantContextHolderFilter,\
|
||||
com.pig4cloud.pigx.common.data.tenant.PigxFeignTenantConfiguration,\
|
||||
com.pig4cloud.pigx.common.data.mybatis.MybatisPlusConfig
|
||||
+4
@@ -26,6 +26,7 @@ import org.springframework.cloud.gateway.route.RouteDefinition;
|
||||
import org.springframework.cloud.gateway.route.RouteDefinitionRepository;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -51,6 +52,7 @@ public class RedisRouteDefinitionWriter implements RouteDefinitionRepository {
|
||||
RouteDefinitionVo vo = new RouteDefinitionVo();
|
||||
BeanUtils.copyProperties(r, vo);
|
||||
log.info("保存路由信息{}", vo);
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.opsForHash().put(CommonConstants.ROUTE_KEY, r.getId(), vo);
|
||||
return Mono.empty();
|
||||
});
|
||||
@@ -60,6 +62,7 @@ public class RedisRouteDefinitionWriter implements RouteDefinitionRepository {
|
||||
public Mono<Void> delete(Mono<String> routeId) {
|
||||
routeId.subscribe(id -> {
|
||||
log.info("删除路由信息{}", id);
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.opsForHash().delete(CommonConstants.ROUTE_KEY, id);
|
||||
});
|
||||
return Mono.empty();
|
||||
@@ -73,6 +76,7 @@ public class RedisRouteDefinitionWriter implements RouteDefinitionRepository {
|
||||
*/
|
||||
@Override
|
||||
public Flux<RouteDefinition> getRouteDefinitions() {
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(RouteDefinitionVo.class));
|
||||
List<RouteDefinitionVo> values = redisTemplate.opsForHash().values(CommonConstants.ROUTE_KEY);
|
||||
List<RouteDefinition> definitionList = new ArrayList<>();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.pig4cloud.pigx.common.security.filter.TenantContextHolderFilter,\
|
||||
com.pig4cloud.pigx.common.security.feign.PigxFeignClientConfiguration,\
|
||||
com.pig4cloud.pigx.common.security.feign.PigxFeignTenantConfiguration,\
|
||||
com.pig4cloud.pigx.common.data.tenant.PigxFeignTenantConfiguration,\
|
||||
com.pig4cloud.pigx.common.security.service.PigxUserDetailsServiceImpl
|
||||
+1
-1
@@ -33,8 +33,8 @@
|
||||
<description>pigx 公共聚合模块</description>
|
||||
|
||||
<modules>
|
||||
<module>pigx-common-cache</module>
|
||||
<module>pigx-common-core</module>
|
||||
<module>pigx-common-data</module>
|
||||
<module>pigx-common-gateway</module>
|
||||
<module>pigx-common-job</module>
|
||||
<module>pigx-common-log</module>
|
||||
|
||||
@@ -67,9 +67,8 @@
|
||||
</dependency>
|
||||
<!--缓存-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!--接口文档-->
|
||||
<dependency>
|
||||
|
||||
@@ -40,5 +40,11 @@
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--mybatis plus extension,包含了mybatis plus core-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -58,6 +58,11 @@ public class SysRole extends Model<SysRole> {
|
||||
@NotBlank(message = "角色描述 不能为空")
|
||||
private String roleDesc;
|
||||
|
||||
@NotBlank(message = "数据权限类型 不能为空")
|
||||
private Integer dsType;
|
||||
|
||||
private String dsScope;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
|
||||
+5
-4
@@ -19,11 +19,13 @@ package com.pig4cloud.pigx.admin.api.feign;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.feign.factory.RemoteTokenServiceFallbackFactory;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,11 +39,10 @@ public interface RemoteTokenService {
|
||||
* 分页查询token 信息
|
||||
*
|
||||
* @param params 分页参数
|
||||
* @param from 内部调用标志
|
||||
* @return page
|
||||
*/
|
||||
@PostMapping("/token/page")
|
||||
R<Page> getTokenPage(@RequestBody Map<String, Object> params, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
R<Page> getTokenPage(@RequestBody Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 删除token
|
||||
|
||||
+1
-2
@@ -41,11 +41,10 @@ public class RemoteTokenServiceFallbackImpl implements RemoteTokenService {
|
||||
* 分页查询token 信息
|
||||
*
|
||||
* @param params 分页参数
|
||||
* @param from 内部调用标志
|
||||
* @return page
|
||||
*/
|
||||
@Override
|
||||
public R<Page> getTokenPage(Map<String, Object> params, String from) {
|
||||
public R<Page> getTokenPage(Map<String, Object> params) {
|
||||
log.error("调用认证中心查询token 失败", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,15 @@
|
||||
<artifactId>pigx-common-log</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--缓存依赖-->
|
||||
<!--数据库操作-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.connector.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<artifactId>pigx-common-data</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--swagger-->
|
||||
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.admin.config;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.core.parser.ISqlParser;
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
|
||||
import com.pig4cloud.pigx.common.core.datascope.DataScopeInterceptor;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/29
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@MapperScan("com.pig4cloud.pigx.admin.mapper")
|
||||
public class MybatisPlusConfigurer {
|
||||
private static final String[] IGNORETABLES = new String[]{"sys_dept_relation", "sys_role_dept", "sys_role_menu", "sys_user_role", "sys_route_conf", "sys_menu"};
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*
|
||||
* @return PaginationInterceptor
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
TenantSqlParser tenantSqlParser = new TenantSqlParser();
|
||||
tenantSqlParser.setTenantHandler(new TenantHandler() {
|
||||
@Override
|
||||
public Expression getTenantId() {
|
||||
Integer tenantId = TenantContextHolder.getTenantId();
|
||||
log.debug("当前租户为 >> {}", tenantId);
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenantIdColumn() {
|
||||
return "tenant_id";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTableFilter(String tableName) {
|
||||
return ArrayUtil.contains(IGNORETABLES, tableName);
|
||||
}
|
||||
});
|
||||
sqlParserList.add(tenantSqlParser);
|
||||
paginationInterceptor.setSqlParserList(sqlParserList);
|
||||
return paginationInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据权限插件
|
||||
*
|
||||
* @return DataScopeInterceptor
|
||||
*/
|
||||
@Bean
|
||||
public DataScopeInterceptor dataScopeInterceptor() {
|
||||
return new DataScopeInterceptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除插件
|
||||
*
|
||||
* @return LogicSqlInjector
|
||||
*/
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new LogicSqlInjector();
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -18,7 +18,6 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -48,7 +47,7 @@ public class TokenController {
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R getTokenPage(@RequestParam Map<String, Object> params) {
|
||||
return remoteTokenService.getTokenPage(params, SecurityConstants.FROM_IN);
|
||||
return remoteTokenService.getTokenPage(params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.admin.api.dto.UserDTO;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.vo.UserVO;
|
||||
import com.pig4cloud.pigx.common.core.datascope.DataScope;
|
||||
import com.pig4cloud.pigx.common.data.datascope.DataScope;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+24
-28
@@ -33,8 +33,8 @@ import com.pig4cloud.pigx.admin.api.vo.UserVO;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
|
||||
import com.pig4cloud.pigx.admin.service.*;
|
||||
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pigx.common.core.datascope.DataScope;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.datascope.DataScope;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -82,12 +82,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
baseMapper.insert(sysUser);
|
||||
List<SysUserRole> userRoleList = userDto.getRole()
|
||||
.stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).collect(Collectors.toList());
|
||||
.stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).collect(Collectors.toList());
|
||||
return sysUserRoleService.saveBatch(userRoleList);
|
||||
}
|
||||
|
||||
@@ -103,19 +103,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
userInfo.setSysUser(sysUser);
|
||||
//设置角色列表 (ID)
|
||||
List<Integer> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId())
|
||||
.stream()
|
||||
.map(SysRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
.stream()
|
||||
.map(SysRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
userInfo.setRoles(ArrayUtil.toArray(roleIds, Integer.class));
|
||||
|
||||
//设置权限列表(menu.permission)
|
||||
Set<String> permissions = new HashSet<>();
|
||||
roleIds.forEach(roleId -> {
|
||||
List<String> permissionList = sysMenuService.findMenuByRoleId(roleId)
|
||||
.stream()
|
||||
.filter(menuVo -> StringUtils.isNotEmpty(menuVo.getPermission()))
|
||||
.map(MenuVO::getPermission)
|
||||
.collect(Collectors.toList());
|
||||
.stream()
|
||||
.filter(menuVo -> StringUtils.isNotEmpty(menuVo.getPermission()))
|
||||
.map(MenuVO::getPermission)
|
||||
.collect(Collectors.toList());
|
||||
permissions.addAll(permissionList);
|
||||
});
|
||||
userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class));
|
||||
@@ -131,11 +131,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
*/
|
||||
@Override
|
||||
public IPage getUsersWithRolePage(Page page, UserDTO userDTO) {
|
||||
DataScope dataScope = new DataScope();
|
||||
dataScope.setScopeName("deptId");
|
||||
dataScope.setIsOnly(true);
|
||||
dataScope.setDeptIds(getChildDepts());
|
||||
return baseMapper.getUserVosPage(page, userDTO, dataScope);
|
||||
return baseMapper.getUserVosPage(page, userDTO, new DataScope());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +165,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
|
||||
SysUser sysUser = new SysUser();
|
||||
if (StrUtil.isNotBlank(userDto.getPassword())
|
||||
&& StrUtil.isNotBlank(userDto.getNewpassword1())) {
|
||||
&& StrUtil.isNotBlank(userDto.getNewpassword1())) {
|
||||
if (ENCODER.matches(userDto.getPassword(), userVO.getPassword())) {
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
|
||||
} else {
|
||||
@@ -196,7 +192,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
this.updateById(sysUser);
|
||||
|
||||
sysUserRoleService.remove(Wrappers.<SysUserRole>update().lambda()
|
||||
.eq(SysUserRole::getUserId, userDto.getUserId()));
|
||||
.eq(SysUserRole::getUserId, userDto.getUserId()));
|
||||
userDto.getRole().forEach(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
@@ -215,7 +211,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
public List<SysUser> listAncestorUsers(String username) {
|
||||
SysUser sysUser = this.getOne(Wrappers.<SysUser>query().lambda()
|
||||
.eq(SysUser::getUsername, username));
|
||||
.eq(SysUser::getUsername, username));
|
||||
|
||||
SysDept sysDept = sysDeptService.getById(sysUser.getDeptId());
|
||||
if (sysDept == null) {
|
||||
@@ -224,7 +220,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
Integer parentId = sysDept.getParentId();
|
||||
return this.list(Wrappers.<SysUser>query().lambda()
|
||||
.eq(SysUser::getDeptId, parentId));
|
||||
.eq(SysUser::getDeptId, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,11 +232,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
Integer deptId = SecurityUtils.getUser().getDeptId();
|
||||
//获取当前部门的子部门
|
||||
return sysDeptRelationService
|
||||
.list(Wrappers.<SysDeptRelation>query().lambda()
|
||||
.eq(SysDeptRelation::getAncestor, deptId))
|
||||
.stream()
|
||||
.map(SysDeptRelation::getDescendant)
|
||||
.collect(Collectors.toList());
|
||||
.list(Wrappers.<SysDeptRelation>query().lambda()
|
||||
.eq(SysDeptRelation::getAncestor, deptId))
|
||||
.stream()
|
||||
.map(SysDeptRelation::getDescendant)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,8 @@
|
||||
<result column="role_name" property="roleName"/>
|
||||
<result column="role_code" property="roleCode"/>
|
||||
<result column="role_desc" property="roleDesc"/>
|
||||
<result column="ds_type" property="dsType"/>
|
||||
<result column="ds_scope" property="dsScope"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--缓存依赖-->
|
||||
<!--数据依赖-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<artifactId>pigx-common-data</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -54,29 +54,28 @@
|
||||
<artifactId>pigx-upms-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-swagger</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.connector.version}</version>
|
||||
</dependency>
|
||||
<!--mybatis-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-swagger</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!-- activiti -->
|
||||
<dependency>
|
||||
<groupId>org.activiti</groupId>
|
||||
<artifactId>activiti-spring-boot-starter-basic</artifactId>
|
||||
<version>${activiti.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.connector.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.activiti</groupId>
|
||||
<artifactId>activiti-modeler</artifactId>
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import com.pig4cloud.pigx.act.mapper.LeaveBillMapper;
|
||||
import com.pig4cloud.pigx.act.service.ActTaskService;
|
||||
import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.TaskStatusEnum;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.pig4cloud.pigx.act.service.EditorService;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.ActivitiException;
|
||||
|
||||
+12
-12
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.pig4cloud.pigx.act.service.ModelService;
|
||||
import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
@@ -82,8 +82,8 @@ public class ModelServiceImpl implements ModelService {
|
||||
model.setName(name);
|
||||
model.setCategory(category);
|
||||
model.setVersion(Integer.parseInt(
|
||||
String.valueOf(repositoryService.createModelQuery()
|
||||
.modelKey(model.getKey()).count() + 1)));
|
||||
String.valueOf(repositoryService.createModelQuery()
|
||||
.modelKey(model.getKey()).count() + 1)));
|
||||
|
||||
ObjectNode modelObjectNode = objectMapper.createObjectNode();
|
||||
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
|
||||
@@ -110,8 +110,8 @@ public class ModelServiceImpl implements ModelService {
|
||||
@Override
|
||||
public IPage<Model> getModelPage(Map<String, Object> params) {
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery()
|
||||
.modelTenantId(String.valueOf(TenantContextHolder.getTenantId()))
|
||||
.latestVersion().orderByLastUpdateTime().desc();
|
||||
.modelTenantId(String.valueOf(TenantContextHolder.getTenantId()))
|
||||
.latestVersion().orderByLastUpdateTime().desc();
|
||||
String category = (String) params.get("category");
|
||||
if (StrUtil.isNotBlank(category)) {
|
||||
modelQuery.modelCategory(category);
|
||||
@@ -158,18 +158,18 @@ public class ModelServiceImpl implements ModelService {
|
||||
}
|
||||
// 部署流程
|
||||
Deployment deployment = repositoryService
|
||||
.createDeployment().name(model.getName())
|
||||
.addBpmnModel(processName, bpmnModel)
|
||||
.tenantId(String.valueOf(TenantContextHolder.getTenantId()))
|
||||
.deploy();
|
||||
.createDeployment().name(model.getName())
|
||||
.addBpmnModel(processName, bpmnModel)
|
||||
.tenantId(String.valueOf(TenantContextHolder.getTenantId()))
|
||||
.deploy();
|
||||
|
||||
// 设置流程分类
|
||||
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery()
|
||||
.deploymentId(deployment.getId())
|
||||
.list();
|
||||
.deploymentId(deployment.getId())
|
||||
.list();
|
||||
|
||||
list.stream().forEach(processDefinition ->
|
||||
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), model.getCategory()));
|
||||
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), model.getCategory()));
|
||||
} catch (Exception e) {
|
||||
log.error("部署失败,异常", e);
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import com.pig4cloud.pigx.common.core.constant.PaginationConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.ProcessStatusEnum;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.ResourceTypeEnum;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.TaskStatusEnum;
|
||||
import com.pig4cloud.pigx.common.core.util.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
<!--数据操作-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-data</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--mybatis-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<!--缓存依赖-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.codegen.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/29
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan("com.pig4cloud.pigx.codegen.mapper")
|
||||
public class MybatisPlusConfigurer {
|
||||
/**
|
||||
* 分页插件
|
||||
*
|
||||
* @return PaginationInterceptor
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除插件
|
||||
*
|
||||
* @return LogicSqlInjector
|
||||
*/
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new LogicSqlInjector();
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,10 @@
|
||||
<artifactId>pigx-common-swagger</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--缓存依赖-->
|
||||
<!--数据库-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<artifactId>pigx-common-data</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--mybatis-->
|
||||
|
||||
@@ -39,9 +39,8 @@
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-cache</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!--监控服务端-->
|
||||
<dependency>
|
||||
|
||||
+2
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
@@ -47,6 +48,7 @@ public class RedisEventStore extends InMemoryEventStore {
|
||||
events.forEach(event -> {
|
||||
String key = event.getInstance().getValue() + "_" + event.getTimestamp().toString();
|
||||
log.info("保存实例事件的KEY:{},EVENT: {}", key, event.getType());
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(InstanceEvent.class));
|
||||
redisTemplate.opsForHash().put(CommonConstants.EVENT_KEY, key, event);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user