mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-23 05:00:23 +08:00
Merge branch 'dev'
This commit is contained in:
commit
465a594b47
@ -15,7 +15,9 @@
|
||||
|
||||
## 文档视频
|
||||
|
||||
[文档视频 wiki.pig4cloud.com](https://wiki.pig4cloud.com)
|
||||
[ 配套文档 wiki.pig4cloud.com](https://wiki.pig4cloud.com)
|
||||
|
||||
[ 配套视频 bilibili.com/video/BV12t411B7e9](https://www.bilibili.com/video/BV12t411B7e9)
|
||||
|
||||
[PIGX 在线体验 pigx.pig4cloud.com](http://pigx.pig4cloud.com)
|
||||
|
||||
@ -23,7 +25,7 @@
|
||||
|
||||
## 微信群 [禁广告]
|
||||
|
||||
![1628762721](https://minio.pigx.vip/oss/1628762721.png)
|
||||
![](https://minio.pigx.vip/oss/1628762721.png)
|
||||
|
||||
## 快速开始
|
||||
|
||||
@ -35,7 +37,7 @@
|
||||
| Spring Cloud | 2020.0.4 |
|
||||
| Spring Cloud Alibaba | 2021.1 |
|
||||
| Spring Security OAuth2 | 2.3.6 |
|
||||
| Mybatis Plus | 3.4.3.5 |
|
||||
| Mybatis Plus | 3.4.3.4 |
|
||||
| hutool | 5.7.15 |
|
||||
| Avue | 2.6.18 |
|
||||
|
||||
|
@ -13,11 +13,10 @@ DROP TABLE IF EXISTS `gen_datasource_conf`;
|
||||
CREATE TABLE `gen_datasource_conf` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据源名称',
|
||||
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'jdbc-url',
|
||||
`url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'jdbc-url',
|
||||
`username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户名',
|
||||
`password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '密码',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
`driver_class_name` varchar (255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据驱动名称',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
@ -54,4 +53,4 @@ CREATE TABLE `gen_form_conf` (
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-auth</artifactId>
|
||||
|
@ -21,6 +21,7 @@ import com.pig4cloud.pig.common.security.component.PigWebResponseExceptionTransl
|
||||
import com.pig4cloud.pig.common.security.grant.ResourceOwnerCustomeAppTokenGranter;
|
||||
import com.pig4cloud.pig.common.security.service.PigClientDetailsService;
|
||||
import com.pig4cloud.pig.common.security.service.PigCustomTokenServices;
|
||||
import com.pig4cloud.pig.common.security.service.PigUser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -101,6 +102,17 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
||||
return (accessToken, authentication) -> {
|
||||
final Map<String, Object> additionalInfo = new HashMap<>(4);
|
||||
additionalInfo.put(SecurityConstants.DETAILS_LICENSE, SecurityConstants.PROJECT_LICENSE);
|
||||
String clientId = authentication.getOAuth2Request().getClientId();
|
||||
additionalInfo.put(SecurityConstants.CLIENT_ID, clientId);
|
||||
|
||||
// 客户端模式不返回具体用户信息
|
||||
if (SecurityConstants.CLIENT_CREDENTIALS.equals(authentication.getOAuth2Request().getGrantType())) {
|
||||
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
PigUser pigUser = (PigUser) authentication.getUserAuthentication().getPrincipal();
|
||||
additionalInfo.put(SecurityConstants.DETAILS_USER, pigUser);
|
||||
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
|
||||
return accessToken;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common-bom</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>pig-common-bom</name>
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
<properties>
|
||||
<pig.common.version>${project.version}</pig.common.version>
|
||||
<spring-boot.version>2.5.5</spring-boot.version>
|
||||
<spring-boot.version>2.5.6</spring-boot.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<security.oauth.version>2.1.8.RELEASE</security.oauth.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-core</artifactId>
|
||||
|
@ -23,8 +23,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
@ -38,10 +37,10 @@ public class RedisTemplateConfiguration {
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
|
||||
redisTemplate.setKeySerializer(RedisSerializer.string());
|
||||
redisTemplate.setHashKeySerializer(RedisSerializer.string());
|
||||
redisTemplate.setValueSerializer(RedisSerializer.java());
|
||||
redisTemplate.setHashValueSerializer(RedisSerializer.java());
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
return redisTemplate;
|
||||
}
|
||||
|
@ -95,30 +95,15 @@ public interface SecurityConstants {
|
||||
String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter";
|
||||
|
||||
/**
|
||||
* 用户ID字段
|
||||
* 用户信息
|
||||
*/
|
||||
String DETAILS_USER_ID = "user_id";
|
||||
|
||||
/**
|
||||
* 用户名字段
|
||||
*/
|
||||
String DETAILS_USERNAME = "username";
|
||||
|
||||
/**
|
||||
* 用户部门字段
|
||||
*/
|
||||
String DETAILS_DEPT_ID = "dept_id";
|
||||
String DETAILS_USER = "user_info";
|
||||
|
||||
/**
|
||||
* 协议字段
|
||||
*/
|
||||
String DETAILS_LICENSE = "license";
|
||||
|
||||
/**
|
||||
* 用户数据权限信息
|
||||
*/
|
||||
String DETAILS_USER_DATA_SCOPE = "user_data_scope";
|
||||
|
||||
/**
|
||||
* 验证码有效期,默认 60秒
|
||||
*/
|
||||
@ -129,4 +114,14 @@ public interface SecurityConstants {
|
||||
*/
|
||||
String CODE_SIZE = "6";
|
||||
|
||||
/**
|
||||
* 客户端模式
|
||||
*/
|
||||
String CLIENT_CREDENTIALS = "client_credentials";
|
||||
|
||||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
String CLIENT_ID = "clientId";
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -61,9 +61,7 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide
|
||||
String username = rs.getString(DataSourceConstants.DS_USER_NAME);
|
||||
String password = rs.getString(DataSourceConstants.DS_USER_PWD);
|
||||
String url = rs.getString(DataSourceConstants.DS_JDBC_URL);
|
||||
String driverClassName = rs.getString(DataSourceConstants.DS_DRIVER_CLASS_NAME);
|
||||
DataSourceProperty property = new DataSourceProperty();
|
||||
property.setDriverClassName(driverClassName);
|
||||
property.setUsername(username);
|
||||
property.setLazy(true);
|
||||
property.setPassword(stringEncryptor.decrypt(password));
|
||||
@ -77,7 +75,6 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide
|
||||
property.setPassword(properties.getPassword());
|
||||
property.setUrl(properties.getUrl());
|
||||
property.setLazy(true);
|
||||
property.setDriverClassName(property.getDriverClassName());
|
||||
map.put(DataSourceConstants.DS_MASTER, property);
|
||||
return map;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-job</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-log</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-mybatis</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-security</artifactId>
|
||||
|
@ -93,7 +93,7 @@ public class PigRedisTokenStore implements TokenStore {
|
||||
}
|
||||
|
||||
private byte[] serializeKey(String object) {
|
||||
return serialize(object);
|
||||
return serialize(prefix + object);
|
||||
}
|
||||
|
||||
private OAuth2AccessToken deserializeAccessToken(byte[] bytes) {
|
||||
|
@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-swagger</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-common</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common-test</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-common</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-gateway</artifactId>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-register</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-upms</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-upms-api</artifactId>
|
||||
|
@ -53,8 +53,8 @@ public interface RemoteUserService {
|
||||
* @param from 调用标志
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/app/info/{mobile}")
|
||||
R<UserInfo> infoByMobile(@PathVariable("mobile") String mobile, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
@GetMapping("/app/info/{phone}")
|
||||
R<UserInfo> infoByMobile(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
|
||||
/**
|
||||
* 根据部门id,查询对应的用户 id 集合
|
||||
|
@ -56,8 +56,8 @@ public class RemoteUserServiceFallbackImpl implements RemoteUserService {
|
||||
* @return R
|
||||
*/
|
||||
@Override
|
||||
public R<UserInfo> infoByMobile(String mobile, String from) {
|
||||
log.error("feign 查询用户信息失败手机号码:{}", mobile, cause);
|
||||
public R<UserInfo> infoByMobile(String phone, String from) {
|
||||
log.error("feign 查询用户信息失败手机号码:{}", phone, cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-upms</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-upms-biz</artifactId>
|
||||
|
@ -39,11 +39,11 @@ public class AppController {
|
||||
* @return 用户信息
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/info/{mobile}")
|
||||
public R infoByMobile(@PathVariable String mobile) {
|
||||
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, mobile));
|
||||
@GetMapping("/info/{phone}")
|
||||
public R infoByMobile(@PathVariable String phone) {
|
||||
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, phone));
|
||||
if (user == null) {
|
||||
return R.failed(String.format("用户信息为空 %s", mobile));
|
||||
return R.failed(String.format("用户信息为空 %s", phone));
|
||||
}
|
||||
return R.ok(userService.getUserInfo(user));
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
package com.pig4cloud.pig.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.service.SysMenuService;
|
||||
import com.pig4cloud.pig.common.core.util.R;
|
||||
@ -29,6 +27,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -52,9 +51,9 @@ public class MenuController {
|
||||
@GetMapping
|
||||
public R getUserMenu(Integer parentId) {
|
||||
// 获取符合条件的菜单
|
||||
Set<SysMenu> sysMenuList = sysMenuService
|
||||
.findMenuByRoleId(CollUtil.join(SecurityUtils.getRoles(), StrUtil.COMMA));
|
||||
return R.ok(sysMenuService.filterMenu(sysMenuList, parentId));
|
||||
Set<SysMenu> menuSet = SecurityUtils.getRoles().stream().map(sysMenuService::findMenuByRoleId)
|
||||
.flatMap(Collection::stream).collect(Collectors.toSet());
|
||||
return R.ok(sysMenuService.filterMenu(menuSet, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,8 +74,8 @@ public class MenuController {
|
||||
*/
|
||||
@GetMapping("/tree/{roleId}")
|
||||
public R getRoleTree(@PathVariable Integer roleId) {
|
||||
return R.ok(sysMenuService.findMenuByRoleId(String.valueOf(roleId)).stream().map(SysMenu::getMenuId)
|
||||
.collect(Collectors.toList()));
|
||||
return R.ok(
|
||||
sysMenuService.findMenuByRoleId(roleId).stream().map(SysMenu::getMenuId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ public class OauthClientDetailsController {
|
||||
|
||||
/**
|
||||
* 通过ID查询
|
||||
* @param id clientId
|
||||
* @param clientId 客户端id
|
||||
* @return SysOauthClientDetails
|
||||
*/
|
||||
@GetMapping("/{clientId}")
|
||||
|
@ -38,6 +38,6 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
* @param roleId 角色ID
|
||||
* @return
|
||||
*/
|
||||
Set<SysMenu> listMenusByRoleId(String roleIds);
|
||||
Set<SysMenu> listMenusByRoleId(Integer roleIds);
|
||||
|
||||
}
|
||||
|
@ -50,29 +50,28 @@ public class AppServiceImpl implements AppService {
|
||||
|
||||
/**
|
||||
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
|
||||
* @param mobile mobile
|
||||
* @param phone 手机号
|
||||
* @return code
|
||||
*/
|
||||
@Override
|
||||
public R<Boolean> sendSmsCode(String mobile) {
|
||||
List<SysUser> userList = userMapper
|
||||
.selectList(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, mobile));
|
||||
public R<Boolean> sendSmsCode(String phone) {
|
||||
List<SysUser> userList = userMapper.selectList(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, phone));
|
||||
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
log.info("手机号未注册:{}", mobile);
|
||||
log.info("手机号未注册:{}", phone);
|
||||
return R.ok(Boolean.FALSE, "手机号未注册");
|
||||
}
|
||||
|
||||
Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + mobile);
|
||||
Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + phone);
|
||||
|
||||
if (codeObj != null) {
|
||||
log.info("手机号验证码未过期:{},{}", mobile, codeObj);
|
||||
log.info("手机号验证码未过期:{},{}", phone, codeObj);
|
||||
return R.ok(Boolean.FALSE, "验证码发送过频繁");
|
||||
}
|
||||
|
||||
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
|
||||
log.info("手机号生成验证码成功:{},{}", mobile, code);
|
||||
redisTemplate.opsForValue().set(CacheConstants.DEFAULT_CODE_KEY + mobile, code, SecurityConstants.CODE_TIME,
|
||||
log.info("手机号生成验证码成功:{},{}", phone, code);
|
||||
redisTemplate.opsForValue().set(CacheConstants.DEFAULT_CODE_KEY + phone, code, SecurityConstants.CODE_TIME,
|
||||
TimeUnit.SECONDS);
|
||||
return R.ok(Boolean.TRUE, code);
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ public interface SysMenuService extends IService<SysMenu> {
|
||||
|
||||
/**
|
||||
* 通过角色编号查询URL 权限
|
||||
* @param roleIds 角色ID
|
||||
* @param roleId 角色ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
Set<SysMenu> findMenuByRoleId(String roleIds);
|
||||
Set<SysMenu> findMenuByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 级联删除菜单
|
||||
|
@ -61,9 +61,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
private final SysRoleMenuMapper sysRoleMenuMapper;
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleIds + '_menu'", unless = "#result == null")
|
||||
public Set<SysMenu> findMenuByRoleId(String roleIds) {
|
||||
return baseMapper.listMenusByRoleId(roleIds);
|
||||
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")
|
||||
public Set<SysMenu> findMenuByRoleId(Integer roleId) {
|
||||
return baseMapper.listMenusByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,11 +25,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pig.admin.api.dto.UserDTO;
|
||||
import com.pig4cloud.pig.admin.api.dto.UserInfo;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysDept;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysRole;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysUserRole;
|
||||
import com.pig4cloud.pig.admin.api.entity.*;
|
||||
import com.pig4cloud.pig.admin.api.vo.UserExcelVO;
|
||||
import com.pig4cloud.pig.admin.api.vo.UserVO;
|
||||
import com.pig4cloud.pig.admin.mapper.SysDeptMapper;
|
||||
@ -55,10 +51,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -118,10 +111,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
List<Integer> roleIds = roleList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
|
||||
userInfo.setRoles(ArrayUtil.toArray(roleIds, Integer.class));
|
||||
// 设置权限列表(menu.permission)
|
||||
Set<String> permissions = sysMenuService.findMenuByRoleId(CollUtil.join(roleIds, StrUtil.COMMA)).stream()
|
||||
.filter(m -> MenuTypeEnum.BUTTON.getType().equals(m.getType()))
|
||||
.filter(m -> StrUtil.isNotBlank(m.getPermission())).map(SysMenu::getPermission)
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> permissions = roleIds.stream().map(sysMenuService::findMenuByRoleId).flatMap(Collection::stream)
|
||||
.filter(m -> MenuTypeEnum.BUTTON.getType().equals(m.getType())).map(SysMenu::getPermission)
|
||||
.filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
||||
userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class));
|
||||
|
||||
return userInfo;
|
||||
|
@ -43,7 +43,7 @@
|
||||
LEFT JOIN sys_role_menu ON sys_menu.menu_id = sys_role_menu.menu_id
|
||||
WHERE
|
||||
sys_menu.del_flag = 0
|
||||
AND sys_role_menu.role_id IN (#{roleIds})
|
||||
AND sys_role_menu.role_id = #{roleId}
|
||||
ORDER BY
|
||||
sys_menu.sort DESC
|
||||
</select>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-upms</artifactId>
|
||||
|
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-visual</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-codegen</artifactId>
|
||||
|
@ -59,11 +59,6 @@ public class GenDatasourceConf extends BaseEntity {
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 驱动类型
|
||||
*/
|
||||
private String driverClassName;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
|
@ -119,7 +119,6 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfM
|
||||
dataSourceProperty.setUrl(conf.getUrl());
|
||||
dataSourceProperty.setUsername(conf.getUsername());
|
||||
dataSourceProperty.setPassword(conf.getPassword());
|
||||
dataSourceProperty.setDriverClassName(conf.getDriverClassName());
|
||||
dataSourceProperty.setLazy(true);
|
||||
DataSource dataSource = hikariDataSourceCreator.createDataSource(dataSourceProperty);
|
||||
SpringContextHolder.getBean(DynamicRoutingDataSource.class).addDataSource(dataSourceProperty.getPoolName(),
|
||||
|
@ -1,5 +1,3 @@
|
||||
#set($excludeColumns = ["create_time","update_time","create_by","update_by"])
|
||||
|
||||
export const tableOption = {
|
||||
"border": true,
|
||||
"index": true,
|
||||
@ -9,6 +7,7 @@ export const tableOption = {
|
||||
"align": "center",
|
||||
"searchMenuSpan": 6,
|
||||
"column": [
|
||||
#set($excludeColumns = ["create_time","update_time","create_by","update_by"])
|
||||
#foreach ($column in $columns)
|
||||
## 当列是主键 或者 列是审计字段时候, 新增不显示,编辑的时候显示单不能编辑
|
||||
#if($column.columnName == $pk.columnName || $excludeColumns.contains($column.columnName))
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-visual</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-monitor</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-visual</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-sentinel-dashboard</artifactId>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig-visual</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-xxl-job-admin</artifactId>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pig-visual</artifactId>
|
||||
|
6
pom.xml
6
pom.xml
@ -22,7 +22,7 @@
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pig</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<version>3.4.0</version>
|
||||
<version>3.4.1</version>
|
||||
<packaging>pom</packaging>
|
||||
<url>https://www.pig4cloud.com</url>
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<spring-boot-admin.version>2.5.2</spring-boot-admin.version>
|
||||
<hutool.version>5.7.15</hutool.version>
|
||||
<spring-boot-admin.version>2.5.4</spring-boot-admin.version>
|
||||
<hutool.version>5.7.16</hutool.version>
|
||||
<dynamic-ds.version>3.4.1</dynamic-ds.version>
|
||||
<captcha.version>2.2.1</captcha.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
|
Loading…
Reference in New Issue
Block a user