mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 10:36:31 +08:00
删除文件 orange-demo-single-pg
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
/.mvn/*
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/build/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
### 服务接口文档
|
|
||||||
---
|
|
||||||
- Knife4j
|
|
||||||
- 服务启动后,Knife4j的文档入口地址 [http://localhost:8082/doc.html#/plus](http://localhost:8082/doc.html#/plus)
|
|
||||||
- Postman
|
|
||||||
- 无需启动服务,即可将当前工程的接口导出成Postman格式。在工程的common/common-tools/模块下,找到ExportApiApp文件,并执行main函数。
|
|
||||||
|
|
||||||
### 服务启动环境依赖
|
|
||||||
---
|
|
||||||
|
|
||||||
执行docker-compose up -d 命令启动下面依赖的服务。
|
|
||||||
执行docker-compose down 命令停止下面服务。
|
|
||||||
|
|
||||||
- Redis
|
|
||||||
- 版本:4
|
|
||||||
- 端口: 6379
|
|
||||||
- 推荐客户端工具 [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesktopManager)
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>DemoSinglePg</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>application-webadmin</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>application</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.anji-plus</groupId>
|
|
||||||
<artifactId>spring-boot-starter-captcha</artifactId>
|
|
||||||
<version>${ajcaptcha.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- aj-captcha 依赖data-redis作为缓存 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<!-- 业务组件依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-redis</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-log</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-sequence</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-datafilter</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-swagger</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<includes>
|
|
||||||
<include>**/*.*</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/java</directory>
|
|
||||||
<includes>
|
|
||||||
<include>**/*.xml</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.webadmin;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用服务启动类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@EnableAsync
|
|
||||||
@SpringBootApplication
|
|
||||||
@ComponentScan("com.orangeforms")
|
|
||||||
public class WebAdminApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(WebAdminApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.app.util;
|
|
||||||
|
|
||||||
import com.anji.captcha.service.CaptchaCacheService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对于分布式部署的应用,我们建议应用自己实现CaptchaCacheService,比如用Redis,参考service/spring-boot代码示例。
|
|
||||||
* 如果应用是单点的,也没有使用redis,那默认使用内存。
|
|
||||||
* 内存缓存只适合单节点部署的应用,否则验证码生产与验证在节点之间信息不同步,导致失败。
|
|
||||||
*
|
|
||||||
* ☆☆☆ SPI: 在resources目录新建META-INF.services文件夹(两层),参考当前服务resources。
|
|
||||||
* @author lide1202@hotmail.com
|
|
||||||
* @date 2020-05-12
|
|
||||||
*/
|
|
||||||
public class CaptchaCacheServiceRedisImpl implements CaptchaCacheService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String type() {
|
|
||||||
return "redis";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(String key, String value, long expiresInSeconds) {
|
|
||||||
stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exists(String key) {
|
|
||||||
return stringRedisTemplate.hasKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String key) {
|
|
||||||
stringRedisTemplate.delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get(String key) {
|
|
||||||
return stringRedisTemplate.opsForValue().get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long increment(String key, long val) {
|
|
||||||
return stringRedisTemplate.opsForValue().increment(key,val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用程序自定义的程序属性配置文件。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Configuration
|
|
||||||
@ConfigurationProperties(prefix = "application")
|
|
||||||
public class ApplicationConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* token的Http Request Header的key
|
|
||||||
*/
|
|
||||||
private String tokenHeaderKey;
|
|
||||||
/**
|
|
||||||
* token在过期之前,但是已经需要被刷新时,response返回的header信息的key。
|
|
||||||
*/
|
|
||||||
private String refreshedTokenHeaderKey;
|
|
||||||
/**
|
|
||||||
* token 加密用的密钥,该值的长度最少10个字符(过短会报错)。
|
|
||||||
*/
|
|
||||||
private String tokenSigningKey;
|
|
||||||
/**
|
|
||||||
* 令牌的过期时间,单位毫秒
|
|
||||||
*/
|
|
||||||
private Long expiration;
|
|
||||||
/**
|
|
||||||
* 用户密码被重置之后的缺省密码
|
|
||||||
*/
|
|
||||||
private String defaultUserPassword;
|
|
||||||
/**
|
|
||||||
* 上传文件的基础目录
|
|
||||||
*/
|
|
||||||
private String uploadFileBaseDir;
|
|
||||||
/**
|
|
||||||
* 授信ip列表,没有填写表示全部信任。多个ip之间逗号分隔,如: http://10.10.10.1:8080,http://10.10.10.2:8080
|
|
||||||
*/
|
|
||||||
private String credentialIpList;
|
|
||||||
/**
|
|
||||||
* Session的用户权限在Redis中的过期时间(秒)。
|
|
||||||
* 缺省值是 one day
|
|
||||||
*/
|
|
||||||
private int sessionExpiredSeconds = 86400;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据源配置Bean对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableTransactionManagement
|
|
||||||
@MapperScan(value = {"com.orangeforms.webadmin.*.dao", "com.orangeforms.common.*.dao"})
|
|
||||||
public class DataSourceConfig {
|
|
||||||
|
|
||||||
@Bean(initMethod = "init", destroyMethod = "close")
|
|
||||||
@Primary
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
|
||||||
public DataSource druidDataSource() {
|
|
||||||
return DruidDataSourceBuilder.create().build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.config;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
||||||
import org.springframework.web.filter.CorsFilter;
|
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 这里主要配置Web的各种过滤器和监听器等Servlet容器组件。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class FilterConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置Ajax跨域过滤器。
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public CorsFilter corsFilterRegistration(ApplicationConfig applicationConfig) {
|
|
||||||
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
|
|
||||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
|
||||||
if (StringUtils.isNotBlank(applicationConfig.getCredentialIpList())) {
|
|
||||||
if ("*".equals(applicationConfig.getCredentialIpList())) {
|
|
||||||
corsConfiguration.addAllowedOriginPattern("*");
|
|
||||||
} else {
|
|
||||||
String[] credentialIpList = StringUtils.split(applicationConfig.getCredentialIpList(), ",");
|
|
||||||
if (credentialIpList.length > 0) {
|
|
||||||
for (String ip : credentialIpList) {
|
|
||||||
corsConfiguration.addAllowedOrigin(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
corsConfiguration.addAllowedHeader("*");
|
|
||||||
corsConfiguration.addAllowedMethod("*");
|
|
||||||
corsConfiguration.addExposedHeader(applicationConfig.getRefreshedTokenHeaderKey());
|
|
||||||
corsConfiguration.setAllowCredentials(true);
|
|
||||||
configSource.registerCorsConfiguration("/**", corsConfiguration);
|
|
||||||
}
|
|
||||||
return new CorsFilter(configSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean<Filter> characterEncodingFilterRegistration() {
|
|
||||||
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(
|
|
||||||
new org.springframework.web.filter.CharacterEncodingFilter());
|
|
||||||
filterRegistrationBean.addUrlPatterns("/*");
|
|
||||||
filterRegistrationBean.addInitParameter("encoding", StandardCharsets.UTF_8.name());
|
|
||||||
// forceEncoding强制response也被编码,另外即使request中已经设置encoding,forceEncoding也会重新设置
|
|
||||||
filterRegistrationBean.addInitParameter("forceEncoding", "true");
|
|
||||||
filterRegistrationBean.setAsyncSupported(true);
|
|
||||||
return filterRegistrationBean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.config;
|
|
||||||
|
|
||||||
import com.orangeforms.webadmin.interceptor.AuthenticationInterceptor;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所有的项目拦截器都在这里集中配置
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class InterceptorConfig implements WebMvcConfigurer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
|
||||||
registry.addInterceptor(new AuthenticationInterceptor()).addPathPatterns("/admin/**");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.interceptor;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.orangeforms.webadmin.config.ApplicationConfig;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermWhitelist;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermWhitelistService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermService;
|
|
||||||
import com.orangeforms.common.core.annotation.NoAuthInterface;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.ResponseResult;
|
|
||||||
import com.orangeforms.common.core.object.TokenData;
|
|
||||||
import com.orangeforms.common.core.util.ApplicationContextHolder;
|
|
||||||
import com.orangeforms.common.core.util.JwtUtil;
|
|
||||||
import com.orangeforms.common.core.util.RedisKeyUtil;
|
|
||||||
import io.jsonwebtoken.Claims;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.redisson.api.RBucket;
|
|
||||||
import org.redisson.api.RSet;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户Token验证、生成和权限验证的拦截器。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class AuthenticationInterceptor implements HandlerInterceptor {
|
|
||||||
|
|
||||||
private final ApplicationConfig appConfig =
|
|
||||||
ApplicationContextHolder.getBean("applicationConfig");
|
|
||||||
|
|
||||||
private final RedissonClient redissonClient = ApplicationContextHolder.getBean(RedissonClient.class);
|
|
||||||
|
|
||||||
private final SysPermService sysPermService =
|
|
||||||
ApplicationContextHolder.getBean(SysPermService.class);
|
|
||||||
|
|
||||||
private static SysPermWhitelistService sysPermWhitelistService =
|
|
||||||
ApplicationContextHolder.getBean(SysPermWhitelistService.class);
|
|
||||||
|
|
||||||
private static Set<String> whitelistPermSet;
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<SysPermWhitelist> sysPermWhitelistList = sysPermWhitelistService.getAllList();
|
|
||||||
whitelistPermSet = sysPermWhitelistList.stream()
|
|
||||||
.map(SysPermWhitelist::getPermUrl).collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
|
||||||
throws Exception {
|
|
||||||
String url = request.getRequestURI();
|
|
||||||
String token = request.getHeader(appConfig.getTokenHeaderKey());
|
|
||||||
boolean noLoginUrl = false;
|
|
||||||
// 如果接口方法标记NoAuthInterface注解,可以直接跳过Token鉴权验证,这里主要为了测试接口方便
|
|
||||||
if (handler instanceof HandlerMethod) {
|
|
||||||
HandlerMethod hm = (HandlerMethod) handler;
|
|
||||||
if (hm.getBeanType().getAnnotation(NoAuthInterface.class) != null
|
|
||||||
|| hm.getMethodAnnotation(NoAuthInterface.class) != null) {
|
|
||||||
noLoginUrl = true;
|
|
||||||
if (StringUtils.isBlank(token)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isBlank(token)) {
|
|
||||||
token = request.getParameter(appConfig.getTokenHeaderKey());
|
|
||||||
}
|
|
||||||
Claims c = JwtUtil.parseToken(token, appConfig.getTokenSigningKey());
|
|
||||||
if (JwtUtil.isNullOrExpired(c)) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
|
||||||
this.outputResponseMessage(response,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, "用户会话已过期或尚未登录,请重新登录!"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String sessionId = (String) c.get("sessionId");
|
|
||||||
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(sessionId);
|
|
||||||
RBucket<String> sessionData = redissonClient.getBucket(sessionIdKey);
|
|
||||||
TokenData tokenData = null;
|
|
||||||
if (sessionData.isExists()) {
|
|
||||||
tokenData = JSON.parseObject(sessionData.get(), TokenData.class);
|
|
||||||
}
|
|
||||||
if (tokenData == null) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
|
||||||
this.outputResponseMessage(response,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, "用户会话已失效,请重新登录!"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
TokenData.addToRequest(tokenData);
|
|
||||||
// 如果url是免登陆、白名单中,则不需要进行鉴权操作
|
|
||||||
if (!noLoginUrl && Boolean.FALSE.equals(tokenData.getIsAdmin()) && !whitelistPermSet.contains(url)) {
|
|
||||||
RSet<String> permSet = redissonClient.getSet(RedisKeyUtil.makeSessionPermIdKey(sessionId));
|
|
||||||
if (!permSet.contains(url)) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
this.outputResponseMessage(response, ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (JwtUtil.needToRefresh(c)) {
|
|
||||||
String refreshedToken = JwtUtil.generateToken(c, appConfig.getExpiration(), appConfig.getTokenSigningKey());
|
|
||||||
response.addHeader(appConfig.getRefreshedTokenHeaderKey(), refreshedToken);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
|
||||||
ModelAndView modelAndView) throws Exception {
|
|
||||||
// 这里需要空注解,否则sonar会不happy。
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
|
||||||
throws Exception {
|
|
||||||
// 这里需要空注解,否则sonar会不happy。
|
|
||||||
}
|
|
||||||
|
|
||||||
private void outputResponseMessage(HttpServletResponse response, ResponseResult<Object> respObj) {
|
|
||||||
PrintWriter out;
|
|
||||||
try {
|
|
||||||
out = response.getWriter();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Failed to call OutputResponseMessage.", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
response.setContentType("application/json; charset=utf-8");
|
|
||||||
out.print(JSON.toJSONString(respObj));
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,342 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import com.anji.captcha.model.common.ResponseModel;
|
|
||||||
import com.anji.captcha.model.vo.CaptchaVO;
|
|
||||||
import com.anji.captcha.service.CaptchaService;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.config.ApplicationConfig;
|
|
||||||
import com.orangeforms.webadmin.upms.service.*;
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysUserStatus;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysUserType;
|
|
||||||
import com.orangeforms.common.core.annotation.NoAuthInterface;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.upload.*;
|
|
||||||
import com.orangeforms.common.redis.cache.SessionCacheHelper;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.redisson.api.RBucket;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录接口控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiSupport(order = 1)
|
|
||||||
@Api(tags = "用户登录接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/login")
|
|
||||||
public class LoginController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserService sysUserService;
|
|
||||||
@Autowired
|
|
||||||
private SysMenuService sysMenuService;
|
|
||||||
@Autowired
|
|
||||||
private SysPermCodeService sysPermCodeService;
|
|
||||||
@Autowired
|
|
||||||
private SysPermService sysPermService;
|
|
||||||
@Autowired
|
|
||||||
private SysRoleService sysRoleService;
|
|
||||||
@Autowired
|
|
||||||
private SysDataPermService sysDataPermService;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig appConfig;
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
@Autowired
|
|
||||||
private SessionCacheHelper cacheHelper;
|
|
||||||
@Autowired
|
|
||||||
private PasswordEncoder passwordEncoder;
|
|
||||||
@Autowired
|
|
||||||
private CaptchaService captchaService;
|
|
||||||
@Autowired
|
|
||||||
private UpDownloaderFactory upDownloaderFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录接口。
|
|
||||||
*
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @param password 密码。
|
|
||||||
* @param captchaVerification 验证码。
|
|
||||||
* @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。
|
|
||||||
*/
|
|
||||||
@ApiImplicitParams({
|
|
||||||
// 这里包含密码密文,仅用于方便开发期间的接口测试,集成测试和发布阶段,需要将当前注解去掉。
|
|
||||||
// 如果您重新生成了公钥和私钥,请替换password的缺省值。
|
|
||||||
@ApiImplicitParam(name = "loginName", defaultValue = "admin"),
|
|
||||||
@ApiImplicitParam(name = "password", defaultValue = "IP3ccke3GhH45iGHB5qP9p7iZw6xUyj28Ju10rnBiPKOI35sc%2BjI7%2FdsjOkHWMfUwGYGfz8ik31HC2Ruk%2Fhkd9f6RPULTHj7VpFdNdde2P9M4mQQnFBAiPM7VT9iW3RyCtPlJexQ3nAiA09OqG%2F0sIf1kcyveSrulxembARDbDo%3D"),
|
|
||||||
@ApiImplicitParam(name = "captchaVerification", defaultValue = "为了方便测试,这里可以修改一下代码,hardcode一个每次都ok的验证码")
|
|
||||||
})
|
|
||||||
@NoAuthInterface
|
|
||||||
@OperationLog(type = SysOperationLogType.LOGIN, saveResponse = false)
|
|
||||||
@PostMapping("/doLogin")
|
|
||||||
public ResponseResult<JSONObject> doLogin(
|
|
||||||
@MyRequestBody String loginName,
|
|
||||||
@MyRequestBody String password,
|
|
||||||
@MyRequestBody String captchaVerification) throws Exception {
|
|
||||||
if (MyCommonUtil.existBlankArgument(loginName, password, captchaVerification)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
String errorMessage;
|
|
||||||
CaptchaVO captchaVO = new CaptchaVO();
|
|
||||||
captchaVO.setCaptchaVerification(captchaVerification);
|
|
||||||
ResponseModel response = captchaService.verification(captchaVO);
|
|
||||||
if (!response.isSuccess()) {
|
|
||||||
//验证码校验失败,返回信息告诉前端
|
|
||||||
//repCode 0000 无异常,代表成功
|
|
||||||
//repCode 9999 服务器内部异常
|
|
||||||
//repCode 0011 参数不能为空
|
|
||||||
//repCode 6110 验证码已失效,请重新获取
|
|
||||||
//repCode 6111 验证失败
|
|
||||||
//repCode 6112 获取验证码失败,请联系管理员
|
|
||||||
errorMessage = String.format("数据验证失败,验证码错误,错误码 [%s] 错误信息 [%s]",
|
|
||||||
response.getRepCode(), response.getRepMsg());
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysUser user = sysUserService.getSysUserByLoginName(loginName);
|
|
||||||
password = URLDecoder.decode(password, StandardCharsets.UTF_8.name());
|
|
||||||
// NOTE: 第一次使用时,请务必阅读ApplicationConstant.PRIVATE_KEY的代码注释。
|
|
||||||
// 执行RsaUtil工具类中的main函数,可以生成新的公钥和私钥。
|
|
||||||
password = RsaUtil.decrypt(password, ApplicationConstant.PRIVATE_KEY);
|
|
||||||
if (user == null || !passwordEncoder.matches(password, user.getPassword())) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USERNAME_PASSWORD);
|
|
||||||
}
|
|
||||||
if (user.getUserStatus() == SysUserStatus.STATUS_LOCKED) {
|
|
||||||
errorMessage = "登录失败,用户账号被锁定!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USER_STATUS, errorMessage);
|
|
||||||
}
|
|
||||||
JSONObject jsonData = this.buildLoginData(user);
|
|
||||||
return ResponseResult.success(jsonData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登出操作。同时将Session相关的信息从缓存中删除。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.LOGOUT)
|
|
||||||
@PostMapping("/doLogout")
|
|
||||||
public ResponseResult<Void> doLogout() {
|
|
||||||
TokenData tokenData = TokenData.takeFromRequest();
|
|
||||||
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(tokenData.getSessionId());
|
|
||||||
redissonClient.getBucket(sessionIdKey).delete();
|
|
||||||
sysPermService.removeUserSysPermCache(tokenData.getSessionId());
|
|
||||||
sysDataPermService.removeDataPermCache(tokenData.getSessionId());
|
|
||||||
cacheHelper.removeAllSessionCache(tokenData.getSessionId());
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在登录之后,通过token再次获取登录信息。
|
|
||||||
* 用于在当前浏览器登录系统后,在新tab页中可以免密登录。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/getLoginInfo")
|
|
||||||
public ResponseResult<JSONObject> getLoginInfo() {
|
|
||||||
TokenData tokenData = TokenData.takeFromRequest();
|
|
||||||
// 这里解释一下为什么没有缓存menuList和permCodeList。
|
|
||||||
// 1. 该操作和权限验证不同,属于低频操作。
|
|
||||||
// 2. 第一次登录和再次获取登录信息之间,如果修改了用户的权限,那么本次获取的是最新权限。
|
|
||||||
// 3. 上一个问题无法避免,因为即便缓存也是有过期时间的,过期之后还是要从数据库获取的。
|
|
||||||
JSONObject jsonData = new JSONObject();
|
|
||||||
jsonData.put("showName", tokenData.getShowName());
|
|
||||||
jsonData.put("isAdmin", tokenData.getIsAdmin());
|
|
||||||
if (StrUtil.isNotBlank(tokenData.getHeadImageUrl())) {
|
|
||||||
jsonData.put("headImageUrl", tokenData.getHeadImageUrl());
|
|
||||||
}
|
|
||||||
Collection<SysMenu> menuList;
|
|
||||||
Collection<String> permCodeList;
|
|
||||||
if (tokenData.getIsAdmin()) {
|
|
||||||
menuList = sysMenuService.getAllMenuList();
|
|
||||||
permCodeList = sysPermCodeService.getAllPermCodeList();
|
|
||||||
} else {
|
|
||||||
menuList = sysMenuService.getMenuListByUserId(tokenData.getUserId());
|
|
||||||
permCodeList = sysPermCodeService.getPermCodeListByUserId(tokenData.getUserId());
|
|
||||||
}
|
|
||||||
jsonData.put("menuList", menuList);
|
|
||||||
jsonData.put("permCodeList", permCodeList);
|
|
||||||
return ResponseResult.success(jsonData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户修改自己的密码。
|
|
||||||
*
|
|
||||||
* @param oldPass 原有密码。
|
|
||||||
* @param newPass 新密码。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@PostMapping("/changePassword")
|
|
||||||
public ResponseResult<Void> changePassword(
|
|
||||||
@MyRequestBody String oldPass, @MyRequestBody String newPass) throws Exception {
|
|
||||||
if (MyCommonUtil.existBlankArgument(newPass, oldPass)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
TokenData tokenData = TokenData.takeFromRequest();
|
|
||||||
SysUser user = sysUserService.getById(tokenData.getUserId());
|
|
||||||
oldPass = URLDecoder.decode(oldPass, StandardCharsets.UTF_8.name());
|
|
||||||
// NOTE: 第一次使用时,请务必阅读ApplicationConstant.PRIVATE_KEY的代码注释。
|
|
||||||
// 执行RsaUtil工具类中的main函数,可以生成新的公钥和私钥。
|
|
||||||
oldPass = RsaUtil.decrypt(oldPass, ApplicationConstant.PRIVATE_KEY);
|
|
||||||
if (user == null || !passwordEncoder.matches(oldPass, user.getPassword())) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USERNAME_PASSWORD);
|
|
||||||
}
|
|
||||||
newPass = URLDecoder.decode(newPass, StandardCharsets.UTF_8.name());
|
|
||||||
newPass = RsaUtil.decrypt(newPass, ApplicationConstant.PRIVATE_KEY);
|
|
||||||
if (!sysUserService.changePassword(tokenData.getUserId(), newPass)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传并修改用户头像。
|
|
||||||
*
|
|
||||||
* @param uploadFile 上传的头像文件。
|
|
||||||
*/
|
|
||||||
@PostMapping("/changeHeadImage")
|
|
||||||
public void changeHeadImage(
|
|
||||||
@RequestParam("uploadFile") MultipartFile uploadFile) throws Exception {
|
|
||||||
String fieldName = "headImageUrl";
|
|
||||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, fieldName);
|
|
||||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
|
||||||
UploadResponseInfo responseInfo = upDownloader.doUpload(null,
|
|
||||||
appConfig.getUploadFileBaseDir(), SysUser.class.getSimpleName(), fieldName, true, uploadFile);
|
|
||||||
if (responseInfo.getUploadFailed()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
responseInfo.setDownloadUri("/admin/upms/login/downloadHeadImage");
|
|
||||||
String newHeadImage = JSONArray.toJSONString(CollUtil.newArrayList(responseInfo));
|
|
||||||
if (!sysUserService.changeHeadImage(TokenData.takeFromRequest().getUserId(), newHeadImage)) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ResponseResult.output(ResponseResult.success(responseInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载用户头像。
|
|
||||||
*
|
|
||||||
* @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。
|
|
||||||
* @param response Http 应答对象。
|
|
||||||
*/
|
|
||||||
@GetMapping("/downloadHeadImage")
|
|
||||||
public void downloadHeadImage(String filename, HttpServletResponse response) {
|
|
||||||
try {
|
|
||||||
SysUser user = sysUserService.getById(TokenData.takeFromRequest().getUserId());
|
|
||||||
if (user == null) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(user.getHeadImageUrl())) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!BaseUpDownloader.containFile(user.getHeadImageUrl(), filename)) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String fieldName = "headImageUrl";
|
|
||||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, fieldName);
|
|
||||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
|
||||||
upDownloader.doDownload(appConfig.getUploadFileBaseDir(),
|
|
||||||
SysUser.class.getSimpleName(), fieldName, filename, true, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSONObject buildLoginData(SysUser user) {
|
|
||||||
int deviceType = MyCommonUtil.getDeviceType();
|
|
||||||
boolean isAdmin = user.getUserType() == SysUserType.TYPE_ADMIN;
|
|
||||||
String headImageUrl = user.getHeadImageUrl();
|
|
||||||
Map<String, Object> claims = new HashMap<>(3);
|
|
||||||
String sessionId = user.getLoginName() + "_" + deviceType + "_" + MyCommonUtil.generateUuid();
|
|
||||||
claims.put("sessionId", sessionId);
|
|
||||||
String token = JwtUtil.generateToken(claims, appConfig.getExpiration(), appConfig.getTokenSigningKey());
|
|
||||||
JSONObject jsonData = new JSONObject();
|
|
||||||
jsonData.put(TokenData.REQUEST_ATTRIBUTE_NAME, token);
|
|
||||||
jsonData.put("showName", user.getShowName());
|
|
||||||
jsonData.put("isAdmin", isAdmin);
|
|
||||||
if (StrUtil.isNotBlank(headImageUrl)) {
|
|
||||||
jsonData.put("headImageUrl", headImageUrl);
|
|
||||||
}
|
|
||||||
TokenData tokenData = new TokenData();
|
|
||||||
tokenData.setSessionId(sessionId);
|
|
||||||
tokenData.setUserId(user.getUserId());
|
|
||||||
tokenData.setDeptId(user.getDeptId());
|
|
||||||
tokenData.setLoginName(user.getLoginName());
|
|
||||||
tokenData.setShowName(user.getShowName());
|
|
||||||
tokenData.setIsAdmin(isAdmin);
|
|
||||||
tokenData.setLoginIp(IpUtil.getRemoteIpAddress(ContextUtil.getHttpRequest()));
|
|
||||||
tokenData.setLoginTime(new Date());
|
|
||||||
tokenData.setDeviceType(deviceType);
|
|
||||||
if (StrUtil.isNotBlank(headImageUrl)) {
|
|
||||||
tokenData.setHeadImageUrl(headImageUrl);
|
|
||||||
}
|
|
||||||
List<SysUserRole> userRoleList = sysRoleService.getSysUserRoleListByUserId(user.getUserId());
|
|
||||||
if (CollectionUtils.isNotEmpty(userRoleList)) {
|
|
||||||
Set<Long> userRoleIdSet = userRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet());
|
|
||||||
tokenData.setRoleIds(StringUtils.join(userRoleIdSet, ","));
|
|
||||||
}
|
|
||||||
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(sessionId);
|
|
||||||
String sessionData = JSON.toJSONString(tokenData, SerializerFeature.WriteNonStringValueAsString);
|
|
||||||
RBucket<String> bucket = redissonClient.getBucket(sessionIdKey);
|
|
||||||
bucket.set(sessionData);
|
|
||||||
bucket.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS);
|
|
||||||
// 这里手动将TokenData存入request,便于OperationLogAspect统一处理操作日志。
|
|
||||||
TokenData.addToRequest(tokenData);
|
|
||||||
Collection<SysMenu> menuList;
|
|
||||||
Collection<String> permCodeList;
|
|
||||||
if (isAdmin) {
|
|
||||||
menuList = sysMenuService.getAllMenuList();
|
|
||||||
permCodeList = sysPermCodeService.getAllPermCodeList();
|
|
||||||
} else {
|
|
||||||
menuList = sysMenuService.getMenuListByUserId(user.getUserId());
|
|
||||||
permCodeList = sysPermCodeService.getPermCodeListByUserId(user.getUserId());
|
|
||||||
}
|
|
||||||
jsonData.put("menuList", menuList);
|
|
||||||
jsonData.put("permCodeList", permCodeList);
|
|
||||||
if (user.getUserType() != SysUserType.TYPE_ADMIN) {
|
|
||||||
// 缓存用户的权限资源
|
|
||||||
sysPermService.putUserSysPermCache(sessionId, user.getUserId());
|
|
||||||
sysDataPermService.putDataPermCache(sessionId, user.getUserId(), user.getDeptId());
|
|
||||||
}
|
|
||||||
return jsonData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.RedisKeyUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.redisson.api.RBucket;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线用户控制器对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "在线用户接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/loginUser")
|
|
||||||
public class LoginUserController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示在线用户列表。
|
|
||||||
*
|
|
||||||
* @param loginName 登录名过滤。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 登录用户信息列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<LoginUserInfo>> list(
|
|
||||||
@MyRequestBody String loginName, @MyRequestBody MyPageParam pageParam) {
|
|
||||||
int queryCount = pageParam.getPageNum() * pageParam.getPageSize();
|
|
||||||
int skipCount = (pageParam.getPageNum() - 1) * pageParam.getPageSize();
|
|
||||||
String patternKey;
|
|
||||||
if (StrUtil.isBlank(loginName)) {
|
|
||||||
patternKey = RedisKeyUtil.getSessionIdPrefix() + "*";
|
|
||||||
} else {
|
|
||||||
patternKey = RedisKeyUtil.getSessionIdPrefix(loginName) + "*";
|
|
||||||
}
|
|
||||||
List<LoginUserInfo> loginUserInfoList = new LinkedList<>();
|
|
||||||
Iterable<String> keys = redissonClient.getKeys().getKeysByPattern(patternKey);
|
|
||||||
for (String key : keys) {
|
|
||||||
loginUserInfoList.add(this.buildTokenDataByRedisKey(key));
|
|
||||||
}
|
|
||||||
loginUserInfoList.sort((o1, o2) -> (int) (o2.getLoginTime().getTime() - o1.getLoginTime().getTime()));
|
|
||||||
int toIndex = Math.min(skipCount + pageParam.getPageSize(), loginUserInfoList.size());
|
|
||||||
List<LoginUserInfo> resultList = loginUserInfoList.subList(skipCount, toIndex);
|
|
||||||
return ResponseResult.success(new MyPageData<>(resultList, (long) loginUserInfoList.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 强制下线指定登录会话。
|
|
||||||
*
|
|
||||||
* @param sessionId 待强制下线的SessionId。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody String sessionId) {
|
|
||||||
// 为了保证被剔除用户正在进行的操作不被干扰,这里只是删除sessionIdKey即可,这样可以使强制下线操作更加平滑。
|
|
||||||
// 比如,如果删除操作权限或数据权限的redis session key,那么正在请求数据的操作就会报错。
|
|
||||||
redissonClient.getBucket(RedisKeyUtil.makeSessionIdKey(sessionId)).delete();
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
private LoginUserInfo buildTokenDataByRedisKey(String key) {
|
|
||||||
RBucket<String> sessionData = redissonClient.getBucket(key);
|
|
||||||
TokenData tokenData = JSON.parseObject(sessionData.get(), TokenData.class);
|
|
||||||
return BeanUtil.copyProperties(tokenData, LoginUserInfo.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,300 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysDataPermDto;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysUserDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysDataPermVo;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysUserVo;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysDataPerm;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysUser;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysDataPermService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysUserService;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限接口控制器对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "数据权限管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysDataPerm")
|
|
||||||
public class SysDataPermController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysDataPermService sysDataPermService;
|
|
||||||
@Autowired
|
|
||||||
private SysUserService sysUserService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加新数据权限操作。
|
|
||||||
*
|
|
||||||
* @param sysDataPermDto 新增对象。
|
|
||||||
* @param deptIdListString 数据权限关联的部门Id列表,多个之间逗号分隔。
|
|
||||||
* @return 应答结果对象。包含新增数据权限对象的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"sysDataPermDto.dataPermId",
|
|
||||||
"sysDataPermDto.createTimeStart",
|
|
||||||
"sysDataPermDto.createTimeEnd",
|
|
||||||
"sysDataPermDto.searchString"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(
|
|
||||||
@MyRequestBody SysDataPermDto sysDataPermDto, @MyRequestBody String deptIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysDataPermDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysDataPerm sysDataPerm = MyModelUtil.copyTo(sysDataPermDto, SysDataPerm.class);
|
|
||||||
CallResult result = sysDataPermService.verifyRelatedData(sysDataPerm, deptIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> deptIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
sysDataPermService.saveNew(sysDataPerm, deptIdSet);
|
|
||||||
return ResponseResult.success(sysDataPerm.getDataPermId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据权限操作。
|
|
||||||
*
|
|
||||||
* @param sysDataPermDto 更新的数据权限对象。
|
|
||||||
* @param deptIdListString 数据权限关联的部门Id列表,多个之间逗号分隔。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"sysDataPermDto.createTimeStart",
|
|
||||||
"sysDataPermDto.createTimeEnd",
|
|
||||||
"sysDataPermDto.searchString"})
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(
|
|
||||||
@MyRequestBody SysDataPermDto sysDataPermDto, @MyRequestBody String deptIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysDataPermDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysDataPerm originalSysDataPerm = sysDataPermService.getById(sysDataPermDto.getDataPermId());
|
|
||||||
if (originalSysDataPerm == null) {
|
|
||||||
errorMessage = "数据验证失败,当前数据权限并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
SysDataPerm sysDataPerm = MyModelUtil.copyTo(sysDataPermDto, SysDataPerm.class);
|
|
||||||
CallResult result = sysDataPermService.verifyRelatedData(sysDataPerm, deptIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> deptIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
if (!sysDataPermService.update(sysDataPerm, originalSysDataPerm, deptIdSet)) {
|
|
||||||
errorMessage = "更新失败,数据不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除数据权限操作。
|
|
||||||
*
|
|
||||||
* @param dataPermId 待删除数据权限主键Id。
|
|
||||||
* @return 应答数据结果。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long dataPermId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(dataPermId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysDataPermService.remove(dataPermId)) {
|
|
||||||
String errorMessage = "数据操作失败,数据权限不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看数据权限列表。
|
|
||||||
*
|
|
||||||
* @param sysDataPermDtoFilter 数据权限查询过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象。包含数据权限列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<SysDataPermVo>> list(
|
|
||||||
@MyRequestBody SysDataPermDto sysDataPermDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysDataPerm filter = MyModelUtil.copyTo(sysDataPermDtoFilter, SysDataPerm.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysDataPerm.class);
|
|
||||||
List<SysDataPerm> dataPermList = sysDataPermService.getSysDataPermList(filter, orderBy);
|
|
||||||
List<SysDataPermVo> dataPermVoList = MyModelUtil.copyCollectionTo(dataPermList, SysDataPermVo.class);
|
|
||||||
long totalCount = 0L;
|
|
||||||
if (dataPermList instanceof Page) {
|
|
||||||
totalCount = ((Page<SysDataPerm>) dataPermList).getTotal();
|
|
||||||
}
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(dataPermVoList, totalCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看单条数据权限详情。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限的主键Id。
|
|
||||||
* @return 应答结果对象,包含数据权限的详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysDataPermVo> view(@RequestParam Long dataPermId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(dataPermId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
SysDataPerm dataPerm = sysDataPermService.getByIdWithRelation(dataPermId, MyRelationParam.full());
|
|
||||||
if (dataPerm == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysDataPermVo dataPermVo = MyModelUtil.copyTo(dataPerm, SysDataPermVo.class);
|
|
||||||
return ResponseResult.success(dataPermVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取不包含指定数据权限Id的用户列表。
|
|
||||||
* 用户和数据权限是多对多关系,当前接口将返回没有赋值指定DataPermId的用户列表。可用于给数据权限添加新用户。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @param sysUserDtoFilter 用户数据的过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含用户列表数据。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listNotInDataPermUser")
|
|
||||||
public ResponseResult<MyPageData<SysUserVo>> listNotInDataPermUser(
|
|
||||||
@MyRequestBody Long dataPermId,
|
|
||||||
@MyRequestBody SysUserDto sysUserDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
ResponseResult<Void> verifyResult = this.doDataPermUserVerify(dataPermId);
|
|
||||||
if (!verifyResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(verifyResult);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
|
||||||
List<SysUser> userList =
|
|
||||||
sysUserService.getNotInSysUserListByDataPermId(dataPermId, filter, orderBy);
|
|
||||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拥有指定数据权限的用户列表。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限Id。
|
|
||||||
* @param sysUserDtoFilter 用户过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含用户列表数据。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDataPermUser")
|
|
||||||
public ResponseResult<MyPageData<SysUserVo>> listDataPermUser(
|
|
||||||
@MyRequestBody Long dataPermId,
|
|
||||||
@MyRequestBody SysUserDto sysUserDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
ResponseResult<Void> verifyResult = this.doDataPermUserVerify(dataPermId);
|
|
||||||
if (!verifyResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(verifyResult);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
|
||||||
List<SysUser> userList =
|
|
||||||
sysUserService.getSysUserListByDataPermId(dataPermId, filter, orderBy);
|
|
||||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doDataPermUserVerify(Long dataPermId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(dataPermId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysDataPermService.existId(dataPermId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为指定数据权限添加用户列表。该操作可同时给一批用户赋值数据权限,并在同一事务内完成。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @param userIdListString 逗号分隔的用户Id列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD_M2M)
|
|
||||||
@PostMapping("/addDataPermUser")
|
|
||||||
public ResponseResult<Void> addDataPermUser(
|
|
||||||
@MyRequestBody Long dataPermId, @MyRequestBody String userIdListString) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(dataPermId, userIdListString)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
Set<Long> userIdSet =
|
|
||||||
Arrays.stream(userIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (!sysDataPermService.existId(dataPermId)
|
|
||||||
|| !sysUserService.existUniqueKeyList("userId", userIdSet)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
sysDataPermService.addDataPermUserList(dataPermId, userIdSet);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为指定用户移除指定数据权限。
|
|
||||||
*
|
|
||||||
* @param dataPermId 指定数据权限主键Id。
|
|
||||||
* @param userId 指定用户主键Id。
|
|
||||||
* @return 应答数据结果。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE_M2M)
|
|
||||||
@PostMapping("/deleteDataPermUser")
|
|
||||||
public ResponseResult<Void> deleteDataPermUser(
|
|
||||||
@MyRequestBody Long dataPermId, @MyRequestBody Long userId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(dataPermId, userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysDataPermService.removeDataPermUser(dataPermId, userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import cn.jimmyshi.beanquery.BeanQuery;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.*;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.*;
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.webadmin.upms.service.*;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.constant.*;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门管理操作控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "部门管理管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysDept")
|
|
||||||
public class SysDeptController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysDeptService sysDeptService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增部门管理数据。
|
|
||||||
*
|
|
||||||
* @param sysDeptDto 新增对象。
|
|
||||||
* @return 应答结果对象,包含新增对象主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysDeptDto.deptId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(@MyRequestBody SysDeptDto sysDeptDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysDeptDto, false);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysDept sysDept = MyModelUtil.copyTo(sysDeptDto, SysDept.class);
|
|
||||||
// 验证父Id的数据合法性
|
|
||||||
SysDept parentSysDept = null;
|
|
||||||
if (MyCommonUtil.isNotBlankOrNull(sysDept.getParentId())) {
|
|
||||||
parentSysDept = sysDeptService.getById(sysDept.getParentId());
|
|
||||||
if (parentSysDept == null) {
|
|
||||||
errorMessage = "数据验证失败,关联的父节点并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sysDept = sysDeptService.saveNew(sysDept, parentSysDept);
|
|
||||||
return ResponseResult.success(sysDept.getDeptId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新部门管理数据。
|
|
||||||
*
|
|
||||||
* @param sysDeptDto 更新对象。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody SysDeptDto sysDeptDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysDeptDto, true);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysDept sysDept = MyModelUtil.copyTo(sysDeptDto, SysDept.class);
|
|
||||||
SysDept originalSysDept = sysDeptService.getById(sysDept.getDeptId());
|
|
||||||
if (originalSysDept == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
// 验证父Id的数据合法性
|
|
||||||
if (MyCommonUtil.isNotBlankOrNull(sysDept.getParentId())
|
|
||||||
&& ObjectUtils.notEqual(sysDept.getParentId(), originalSysDept.getParentId())) {
|
|
||||||
SysDept parentSysDept = sysDeptService.getById(sysDept.getParentId());
|
|
||||||
if (parentSysDept == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,关联的 [父节点] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sysDeptService.update(sysDept, originalSysDept)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除部门管理数据。
|
|
||||||
*
|
|
||||||
* @param deptId 删除对象主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long deptId) {
|
|
||||||
String errorMessage;
|
|
||||||
if (MyCommonUtil.existBlankArgument(deptId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return this.doDelete(deptId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出符合过滤条件的部门管理列表。
|
|
||||||
*
|
|
||||||
* @param sysDeptDtoFilter 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含查询结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<SysDeptVo>> list(
|
|
||||||
@MyRequestBody SysDeptDto sysDeptDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysDept sysDeptFilter = MyModelUtil.copyTo(sysDeptDtoFilter, SysDept.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysDept.class);
|
|
||||||
List<SysDept> sysDeptList = sysDeptService.getSysDeptListWithRelation(sysDeptFilter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(sysDeptList, SysDept.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定部门管理对象详情。
|
|
||||||
*
|
|
||||||
* @param deptId 指定对象主键Id。
|
|
||||||
* @return 应答结果对象,包含对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysDeptVo> view(@RequestParam Long deptId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(deptId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
SysDept sysDept = sysDeptService.getByIdWithRelation(deptId, MyRelationParam.full());
|
|
||||||
if (sysDept == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysDeptVo sysDeptVo = SysDept.INSTANCE.fromModel(sysDept);
|
|
||||||
return ResponseResult.success(sysDeptVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以字典形式返回全部部门管理数据集合。字典的键值为[deptId, deptName]。
|
|
||||||
* 白名单接口,登录用户均可访问。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDict")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict(SysDept filter) {
|
|
||||||
List<SysDept> resultList = sysDeptService.getListByFilter(filter);
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"parentId as parentId", "deptId as id", "deptName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典Id集合,获取查询后的字典数据。
|
|
||||||
*
|
|
||||||
* @param dictIds 字典Id集合。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDictByIds")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByIds(
|
|
||||||
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
|
|
||||||
List<SysDept> resultList = sysDeptService.getInList(new HashSet<>(dictIds));
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"parentId as parentId", "deptId as id", "deptName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据父主键Id,以字典的形式返回其下级数据列表。
|
|
||||||
* 白名单接口,登录用户均可访问。
|
|
||||||
*
|
|
||||||
* @param parentId 父主键Id。
|
|
||||||
* @return 按照字典的形式返回下级数据列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDictByParentId")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByParentId(@RequestParam(required = false) Long parentId) {
|
|
||||||
List<SysDept> resultList = sysDeptService.getListByParentId("parentId", parentId);
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"parentId as parentId", "deptId as id", "deptName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doDelete(Long deptId) {
|
|
||||||
String errorMessage;
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
SysDept originalSysDept = sysDeptService.getById(deptId);
|
|
||||||
if (originalSysDept == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
if (sysDeptService.hasChildren(deptId)) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [对象存在子对象] ,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
|
||||||
}
|
|
||||||
if (sysDeptService.hasChildrenUser(deptId)) {
|
|
||||||
errorMessage = "数据验证失败,请先移除部门用户数据后,再删除当前部门!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
|
||||||
}
|
|
||||||
if (!sysDeptService.remove(deptId)) {
|
|
||||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysMenuDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysMenuVo;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenu;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysMenuType;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysMenuService;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单管理接口控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "菜单管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysMenu")
|
|
||||||
public class SysMenuController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysMenuService sysMenuService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加新菜单操作。
|
|
||||||
*
|
|
||||||
* @param sysMenuDto 新菜单对象。
|
|
||||||
* @param permCodeIdListString 与当前菜单Id绑定的权限Id列表,多个权限之间逗号分隔。
|
|
||||||
* @return 应答结果对象,包含新增菜单的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysMenuDto.menuId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(
|
|
||||||
@MyRequestBody SysMenuDto sysMenuDto, @MyRequestBody String permCodeIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenuDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysMenu sysMenu = MyModelUtil.copyTo(sysMenuDto, SysMenu.class);
|
|
||||||
if (sysMenu.getParentId() != null) {
|
|
||||||
SysMenu parentSysMenu = sysMenuService.getById(sysMenu.getParentId());
|
|
||||||
if (parentSysMenu == null) {
|
|
||||||
errorMessage = "数据验证失败,关联的父菜单不存在!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
if (parentSysMenu.getOnlineFormId() != null) {
|
|
||||||
errorMessage = "数据验证失败,不能动态表单菜单添加父菜单!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CallResult result = sysMenuService.verifyRelatedData(sysMenu, null, permCodeIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> permCodeIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
permCodeIdSet = result.getData().getObject("permCodeIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
sysMenuService.saveNew(sysMenu, permCodeIdSet);
|
|
||||||
return ResponseResult.success(sysMenu.getMenuId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新菜单数据操作。
|
|
||||||
*
|
|
||||||
* @param sysMenuDto 更新菜单对象。
|
|
||||||
* @param permCodeIdListString 与当前菜单Id绑定的权限Id列表,多个权限之间逗号分隔。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(
|
|
||||||
@MyRequestBody SysMenuDto sysMenuDto, @MyRequestBody String permCodeIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenuDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysMenu originalSysMenu = sysMenuService.getById(sysMenuDto.getMenuId());
|
|
||||||
if (originalSysMenu == null) {
|
|
||||||
errorMessage = "数据验证失败,当前菜单并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
SysMenu sysMenu = MyModelUtil.copyTo(sysMenuDto, SysMenu.class);
|
|
||||||
if (ObjectUtil.notEqual(originalSysMenu.getOnlineFormId(), sysMenu.getOnlineFormId())) {
|
|
||||||
if (originalSysMenu.getOnlineFormId() == null) {
|
|
||||||
errorMessage = "数据验证失败,不能为当前菜单添加在线表单Id属性!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
if (sysMenu.getOnlineFormId() == null) {
|
|
||||||
errorMessage = "数据验证失败,不能去掉当前菜单的在线表单Id属性!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (originalSysMenu.getOnlineFormId() != null
|
|
||||||
&& originalSysMenu.getMenuType().equals(SysMenuType.TYPE_BUTTON)) {
|
|
||||||
errorMessage = "数据验证失败,在线表单的内置菜单不能编辑!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
CallResult result = sysMenuService.verifyRelatedData(sysMenu, originalSysMenu, permCodeIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> permCodeIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
permCodeIdSet = result.getData().getObject("permCodeIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
if (!sysMenuService.update(sysMenu, originalSysMenu, permCodeIdSet)) {
|
|
||||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定菜单操作。
|
|
||||||
*
|
|
||||||
* @param menuId 指定菜单主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long menuId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(menuId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
String errorMessage;
|
|
||||||
SysMenu menu = sysMenuService.getById(menuId);
|
|
||||||
if (menu == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
if (menu.getOnlineFormId() != null && menu.getMenuType().equals(SysMenuType.TYPE_BUTTON)) {
|
|
||||||
errorMessage = "数据验证失败,在线表单的内置菜单不能删除!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
// 对于在线表单,无需进行子菜单的验证,而是在删除的时候,连同子菜单一起删除。
|
|
||||||
if (menu.getOnlineFormId() == null && sysMenuService.hasChildren(menuId)) {
|
|
||||||
errorMessage = "数据验证失败,当前菜单存在下级菜单!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
|
||||||
}
|
|
||||||
if (!sysMenuService.remove(menu)) {
|
|
||||||
errorMessage = "数据操作失败,菜单不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取全部菜单列表。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,包含全部菜单数据列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<List<SysMenuVo>> list() {
|
|
||||||
List<SysMenu> sysMenuList = sysMenuService.getAllListByOrder("showOrder");
|
|
||||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(sysMenuList, SysMenuVo.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定菜单数据详情。
|
|
||||||
*
|
|
||||||
* @param menuId 指定菜单主键Id。
|
|
||||||
* @return 应答结果对象,包含菜单详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysMenuVo> view(@RequestParam Long menuId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(menuId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
SysMenu sysMenu = sysMenuService.getByIdWithRelation(menuId, MyRelationParam.full());
|
|
||||||
if (sysMenu == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysMenuVo sysMenuVo = MyModelUtil.copyTo(sysMenu, SysMenuVo.class);
|
|
||||||
return ResponseResult.success(sysMenuVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param url 权限资源地址过滤条件。
|
|
||||||
* @return 应答对象,包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysPermWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysPermWithDetail(Long menuId, String url) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(menuId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysMenuService.getSysPermListWithDetail(menuId, url));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 应答对象,包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysUserWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysUserWithDetail(Long menuId, String loginName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(menuId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysMenuService.getSysUserListWithDetail(menuId, loginName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.util.MyPageUtil;
|
|
||||||
import com.orangeforms.common.log.model.SysOperationLog;
|
|
||||||
import com.orangeforms.common.log.service.SysOperationLogService;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysOperationLogDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysOperationLogVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作日志接口控制器对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "操作日志接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysOperationLog")
|
|
||||||
public class SysOperationLogController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysOperationLogService operationLogService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限列表。
|
|
||||||
*
|
|
||||||
* @param sysOperationLogDtoFilter 操作日志查询过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象。包含操作日志列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<SysOperationLogVo>> list(
|
|
||||||
@MyRequestBody SysOperationLogDto sysOperationLogDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysOperationLog filter = MyModelUtil.copyTo(sysOperationLogDtoFilter, SysOperationLog.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysOperationLog.class);
|
|
||||||
List<SysOperationLog> operationLogList = operationLogService.getSysOperationLogList(filter, orderBy);
|
|
||||||
List<SysOperationLogVo> operationLogVoList = MyModelUtil.copyCollectionTo(operationLogList, SysOperationLogVo.class);
|
|
||||||
long totalCount = 0L;
|
|
||||||
if (operationLogList instanceof Page) {
|
|
||||||
totalCount = ((Page<SysOperationLog>) operationLogList).getTotal();
|
|
||||||
}
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(operationLogVoList, totalCount));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysPermCodeDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysPermCodeVo;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCode;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermCodeService;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字管理接口控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "权限字管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysPermCode")
|
|
||||||
public class SysPermCodeController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermCodeService sysPermCodeService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增权限字操作。
|
|
||||||
*
|
|
||||||
* @param sysPermCodeDto 新增权限字对象。
|
|
||||||
* @param permIdListString 与当前权限Id绑定的权限资源Id列表,多个权限资源之间逗号分隔。
|
|
||||||
* @return 应答结果对象,包含新增权限字的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysPermCodeDto.permCodeId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(
|
|
||||||
@MyRequestBody SysPermCodeDto sysPermCodeDto, @MyRequestBody String permIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCodeDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED);
|
|
||||||
}
|
|
||||||
SysPermCode sysPermCode = MyModelUtil.copyTo(sysPermCodeDto, SysPermCode.class);
|
|
||||||
CallResult result = sysPermCodeService.verifyRelatedData(sysPermCode, null, permIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> permIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
permIdSet = result.getData().getObject("permIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
sysPermCode = sysPermCodeService.saveNew(sysPermCode, permIdSet);
|
|
||||||
return ResponseResult.success(sysPermCode.getPermCodeId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限字操作。
|
|
||||||
*
|
|
||||||
* @param sysPermCodeDto 更新权限字对象。
|
|
||||||
* @param permIdListString 与当前权限Id绑定的权限资源Id列表,多个权限资源之间逗号分隔。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(
|
|
||||||
@MyRequestBody SysPermCodeDto sysPermCodeDto, @MyRequestBody String permIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCodeDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysPermCode originalSysPermCode = sysPermCodeService.getById(sysPermCodeDto.getPermCodeId());
|
|
||||||
if (originalSysPermCode == null) {
|
|
||||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
SysPermCode sysPermCode = MyModelUtil.copyTo(sysPermCodeDto, SysPermCode.class);
|
|
||||||
CallResult result = sysPermCodeService.verifyRelatedData(sysPermCode, originalSysPermCode, permIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> permIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
permIdSet = result.getData().getObject("permIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (!sysPermCodeService.update(sysPermCode, originalSysPermCode, permIdSet)) {
|
|
||||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
} catch (DuplicateKeyException e) {
|
|
||||||
errorMessage = "数据操作失败,权限字编码已经存在!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定权限字操作。
|
|
||||||
*
|
|
||||||
* @param permCodeId 指定的权限字主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long permCodeId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(permCodeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
String errorMessage;
|
|
||||||
if (sysPermCodeService.hasChildren(permCodeId)) {
|
|
||||||
errorMessage = "数据验证失败,当前权限字存在下级权限字!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
|
||||||
}
|
|
||||||
if (!sysPermCodeService.remove(permCodeId)) {
|
|
||||||
errorMessage = "数据操作失败,权限字不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看权限字列表。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,包含权限字列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<List<SysPermCodeVo>> list() {
|
|
||||||
List<SysPermCode> sysPermCodeList =
|
|
||||||
sysPermCodeService.getAllListByOrder("permCodeType", "showOrder");
|
|
||||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(sysPermCodeList, SysPermCodeVo.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看权限字对象详情。
|
|
||||||
*
|
|
||||||
* @param permCodeId 指定权限字主键Id。
|
|
||||||
* @return 应答结果对象,包含权限字对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysPermCodeVo> view(@RequestParam Long permCodeId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(permCodeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
SysPermCode sysPermCode =
|
|
||||||
sysPermCodeService.getByIdWithRelation(permCodeId, MyRelationParam.full());
|
|
||||||
if (sysPermCode == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysPermCodeVo sysPermCodeVo = MyModelUtil.copyTo(sysPermCode, SysPermCodeVo.class);
|
|
||||||
return ResponseResult.success(sysPermCodeVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 应答对象。包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysUserWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysUserWithDetail(Long permCodeId, String loginName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(permCodeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysPermCodeService.getSysUserListWithDetail(permCodeId, loginName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 应答对象。包含从权限字到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysRoleWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysRoleWithDetail(Long permCodeId, String roleName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(permCodeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysPermCodeService.getSysRoleListWithDetail(permCodeId, roleName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysPermDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysPermVo;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPerm;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermService;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源管理接口控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "权限资源管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysPerm")
|
|
||||||
public class SysPermController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermService sysPermService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增权限资源操作。
|
|
||||||
*
|
|
||||||
* @param sysPermDto 新增权限资源对象。
|
|
||||||
* @return 应答结果对象,包含新增权限资源的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysPermDto.permId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(@MyRequestBody SysPermDto sysPermDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysPerm sysPerm = MyModelUtil.copyTo(sysPermDto, SysPerm.class);
|
|
||||||
CallResult result = sysPermService.verifyRelatedData(sysPerm, null);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
sysPerm = sysPermService.saveNew(sysPerm);
|
|
||||||
return ResponseResult.success(sysPerm.getPermId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限资源操作。
|
|
||||||
*
|
|
||||||
* @param sysPermDto 更新权限资源对象。
|
|
||||||
* @return 应答结果对象,包含更新权限资源的主键Id。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody SysPermDto sysPermDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysPerm originalPerm = sysPermService.getById(sysPermDto.getPermId());
|
|
||||||
if (originalPerm == null) {
|
|
||||||
errorMessage = "数据验证失败,当前权限资源并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
SysPerm sysPerm = MyModelUtil.copyTo(sysPermDto, SysPerm.class);
|
|
||||||
CallResult result = sysPermService.verifyRelatedData(sysPerm, originalPerm);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
sysPermService.update(sysPerm, originalPerm);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定权限资源操作。
|
|
||||||
*
|
|
||||||
* @param permId 指定的权限资源主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long permId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(permId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysPermService.remove(permId)) {
|
|
||||||
String errorMessage = "数据操作失败,权限不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看权限资源对象详情。
|
|
||||||
*
|
|
||||||
* @param permId 指定权限资源主键Id。
|
|
||||||
* @return 应答结果对象,包含权限资源对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysPermVo> view(@RequestParam Long permId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(permId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
SysPerm perm = sysPermService.getById(permId);
|
|
||||||
if (perm == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysPermVo permVo = MyModelUtil.copyTo(perm, SysPermVo.class);
|
|
||||||
return ResponseResult.success(permVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看权限资源列表。
|
|
||||||
*
|
|
||||||
* @param sysPermDtoFilter 过滤对象。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含权限资源列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<SysPermVo>> list(
|
|
||||||
@MyRequestBody SysPermDto sysPermDtoFilter, @MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysPerm filter = MyModelUtil.copyTo(sysPermDtoFilter, SysPerm.class);
|
|
||||||
List<SysPerm> permList = sysPermService.getPermListWithRelation(filter);
|
|
||||||
List<SysPermVo> permVoList = MyModelUtil.copyCollectionTo(permList, SysPermVo.class);
|
|
||||||
long totalCount = 0L;
|
|
||||||
if (permList instanceof Page) {
|
|
||||||
totalCount = ((Page<SysPerm>) permList).getTotal();
|
|
||||||
}
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(permVoList, totalCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 应答对象。包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysUserWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysUserWithDetail(Long permId, String loginName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(permId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysPermService.getSysUserListWithDetail(permId, loginName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 应答对象。包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysRoleWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysRoleWithDetail(Long permId, String roleName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(permId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysPermService.getSysRoleListWithDetail(permId, roleName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param menuName 菜单名。
|
|
||||||
* @return 应答对象。包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysMenuWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysMenuWithDetail(Long permId, String menuName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(permId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysPermService.getSysMenuListWithDetail(permId, menuName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysPermModuleDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysPermModuleVo;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPerm;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermModule;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermModuleService;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源模块管理接口控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "权限资源模块管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysPermModule")
|
|
||||||
public class SysPermModuleController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermModuleService sysPermModuleService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增权限资源模块操作。
|
|
||||||
*
|
|
||||||
* @param sysPermModuleDto 新增权限资源模块对象。
|
|
||||||
* @return 应答结果对象,包含新增权限资源模块的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysPermModuleDto.moduleId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(@MyRequestBody SysPermModuleDto sysPermModuleDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModuleDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysPermModule sysPermModule = MyModelUtil.copyTo(sysPermModuleDto, SysPermModule.class);
|
|
||||||
if (sysPermModule.getParentId() != null
|
|
||||||
&& sysPermModuleService.getById(sysPermModule.getParentId()) == null) {
|
|
||||||
errorMessage = "数据验证失败,关联的上级权限模块并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
sysPermModuleService.saveNew(sysPermModule);
|
|
||||||
return ResponseResult.success(sysPermModule.getModuleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限资源模块操作。
|
|
||||||
*
|
|
||||||
* @param sysPermModuleDto 更新权限资源模块对象。
|
|
||||||
* @return 应答结果对象,包含新增权限资源模块的主键Id。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody SysPermModuleDto sysPermModuleDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModuleDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysPermModule sysPermModule = MyModelUtil.copyTo(sysPermModuleDto, SysPermModule.class);
|
|
||||||
SysPermModule originalPermModule = sysPermModuleService.getById(sysPermModule.getModuleId());
|
|
||||||
if (originalPermModule == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
if (sysPermModule.getParentId() != null
|
|
||||||
&& !sysPermModule.getParentId().equals(originalPermModule.getParentId())) {
|
|
||||||
if (sysPermModuleService.getById(sysPermModule.getParentId()) == null) {
|
|
||||||
errorMessage = "数据验证失败,关联的上级权限模块并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sysPermModuleService.update(sysPermModule, originalPermModule)) {
|
|
||||||
errorMessage = "数据验证失败,当前模块并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定权限资源模块操作。
|
|
||||||
*
|
|
||||||
* @param moduleId 指定的权限资源模块主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long moduleId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(moduleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
String errorMessage;
|
|
||||||
if (sysPermModuleService.hasChildren(moduleId)
|
|
||||||
|| sysPermModuleService.hasModulePerms(moduleId)) {
|
|
||||||
errorMessage = "数据验证失败,当前权限模块存在子模块或权限资源,请先删除关联数据!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
|
||||||
}
|
|
||||||
if (!sysPermModuleService.remove(moduleId)) {
|
|
||||||
errorMessage = "数据操作失败,权限模块不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看全部权限资源模块列表。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,包含权限资源模块列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<List<SysPermModuleVo>> list() {
|
|
||||||
List<SysPermModule> permModuleList = sysPermModuleService.getAllListByOrder("showOrder");
|
|
||||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(permModuleList, SysPermModuleVo.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出全部权限资源模块及其下级关联的权限资源列表。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,包含树状列表,结构为权限资源模块和权限资源之间的树状关系。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listAll")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listAll() {
|
|
||||||
List<SysPermModule> sysPermModuleList = sysPermModuleService.getPermModuleAndPermList();
|
|
||||||
List<Map<String, Object>> resultList = new LinkedList<>();
|
|
||||||
for (SysPermModule sysPermModule : sysPermModuleList) {
|
|
||||||
Map<String, Object> permModuleMap = new HashMap<>(5);
|
|
||||||
permModuleMap.put("id", sysPermModule.getModuleId());
|
|
||||||
permModuleMap.put("name", sysPermModule.getModuleName());
|
|
||||||
permModuleMap.put("type", sysPermModule.getModuleType());
|
|
||||||
permModuleMap.put("isPerm", false);
|
|
||||||
if (MyCommonUtil.isNotBlankOrNull(sysPermModule.getParentId())) {
|
|
||||||
permModuleMap.put("parentId", sysPermModule.getParentId());
|
|
||||||
}
|
|
||||||
resultList.add(permModuleMap);
|
|
||||||
if (CollectionUtils.isNotEmpty(sysPermModule.getSysPermList())) {
|
|
||||||
for (SysPerm sysPerm : sysPermModule.getSysPermList()) {
|
|
||||||
Map<String, Object> permMap = new HashMap<>(4);
|
|
||||||
permMap.put("id", sysPerm.getPermId());
|
|
||||||
permMap.put("name", sysPerm.getPermName());
|
|
||||||
permMap.put("isPerm", true);
|
|
||||||
permMap.put("url", sysPerm.getUrl());
|
|
||||||
permMap.put("parentId", sysPermModule.getModuleId());
|
|
||||||
resultList.add(permMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ResponseResult.success(resultList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,358 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import cn.jimmyshi.beanquery.BeanQuery;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysRoleDto;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.SysUserDto;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysRoleVo;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysUserVo;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysRole;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysUser;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysUserRole;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysRoleService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysUserService;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色管理接口控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "角色管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysRole")
|
|
||||||
public class SysRoleController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysRoleService sysRoleService;
|
|
||||||
@Autowired
|
|
||||||
private SysUserService sysUserService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增角色操作。
|
|
||||||
*
|
|
||||||
* @param sysRoleDto 新增角色对象。
|
|
||||||
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。
|
|
||||||
* @return 应答结果对象,包含新增角色的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysRoleDto.roleId", "sysRoleDto.createTimeStart", "sysRoleDto.createTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(
|
|
||||||
@MyRequestBody SysRoleDto sysRoleDto, @MyRequestBody String menuIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class);
|
|
||||||
CallResult result = sysRoleService.verifyRelatedData(sysRole, null, menuIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> menuIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
menuIdSet = result.getData().getObject("menuIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
sysRoleService.saveNew(sysRole, menuIdSet);
|
|
||||||
return ResponseResult.success(sysRole.getRoleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新角色操作。
|
|
||||||
*
|
|
||||||
* @param sysRoleDto 更新角色对象。
|
|
||||||
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"sysRoleDto.createTimeStart", "sysRoleDto.createTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(
|
|
||||||
@MyRequestBody SysRoleDto sysRoleDto, @MyRequestBody String menuIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysRole originalSysRole = sysRoleService.getById(sysRoleDto.getRoleId());
|
|
||||||
if (originalSysRole == null) {
|
|
||||||
errorMessage = "数据验证失败,当前角色并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class);
|
|
||||||
CallResult result = sysRoleService.verifyRelatedData(sysRole, originalSysRole, menuIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> menuIdSet = null;
|
|
||||||
if (result.getData() != null) {
|
|
||||||
menuIdSet = result.getData().getObject("menuIdSet", new TypeReference<Set<Long>>(){});
|
|
||||||
}
|
|
||||||
if (!sysRoleService.update(sysRole, originalSysRole, menuIdSet)) {
|
|
||||||
errorMessage = "更新失败,数据不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定角色操作。
|
|
||||||
*
|
|
||||||
* @param roleId 指定角色主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long roleId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(roleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysRoleService.remove(roleId)) {
|
|
||||||
String errorMessage = "数据操作失败,角色不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看角色列表。
|
|
||||||
*
|
|
||||||
* @param sysRoleDtoFilter 角色过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含角色列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<SysRoleVo>> list(
|
|
||||||
@MyRequestBody SysRoleDto sysRoleDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysRole filter = MyModelUtil.copyTo(sysRoleDtoFilter, SysRole.class);
|
|
||||||
List<SysRole> roleList = sysRoleService.getSysRoleList(
|
|
||||||
filter, MyOrderParam.buildOrderBy(orderParam, SysRole.class));
|
|
||||||
List<SysRoleVo> roleVoList = MyModelUtil.copyCollectionTo(roleList, SysRoleVo.class);
|
|
||||||
long totalCount = 0L;
|
|
||||||
if (roleList instanceof Page) {
|
|
||||||
totalCount = ((Page<SysRole>) roleList).getTotal();
|
|
||||||
}
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(roleVoList, totalCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看角色详情。
|
|
||||||
*
|
|
||||||
* @param roleId 指定角色主键Id。
|
|
||||||
* @return 应答结果对象,包含角色详情对象。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysRoleVo> view(@RequestParam Long roleId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(roleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
SysRole sysRole = sysRoleService.getByIdWithRelation(roleId, MyRelationParam.full());
|
|
||||||
if (sysRole == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysRoleVo sysRoleVo = MyModelUtil.copyTo(sysRole, SysRoleVo.class);
|
|
||||||
return ResponseResult.success(sysRoleVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取不包含指定角色Id的用户列表。
|
|
||||||
* 用户和角色是多对多关系,当前接口将返回没有赋值指定RoleId的用户列表。可用于给角色添加新用户。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @param sysUserDtoFilter 用户过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含用户列表数据。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listNotInUserRole")
|
|
||||||
public ResponseResult<MyPageData<SysUserVo>> listNotInUserRole(
|
|
||||||
@MyRequestBody Long roleId,
|
|
||||||
@MyRequestBody SysUserDto sysUserDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
ResponseResult<Void> verifyResult = this.doRoleUserVerify(roleId);
|
|
||||||
if (!verifyResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(verifyResult);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
|
||||||
List<SysUser> userList = sysUserService.getNotInSysUserListByRoleId(roleId, filter, orderBy);
|
|
||||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拥有指定角色的用户列表。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @param sysUserDtoFilter 用户过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含用户列表数据。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listUserRole")
|
|
||||||
public ResponseResult<MyPageData<SysUserVo>> listUserRole(
|
|
||||||
@MyRequestBody Long roleId,
|
|
||||||
@MyRequestBody SysUserDto sysUserDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
ResponseResult<Void> verifyResult = this.doRoleUserVerify(roleId);
|
|
||||||
if (!verifyResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(verifyResult);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
|
||||||
List<SysUser> userList = sysUserService.getSysUserListByRoleId(roleId, filter, orderBy);
|
|
||||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doRoleUserVerify(Long roleId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(roleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysRoleService.existId(roleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为指定角色添加用户列表。该操作可同时给一批用户赋值角色,并在同一事务内完成。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @param userIdListString 逗号分隔的用户Id列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD_M2M)
|
|
||||||
@PostMapping("/addUserRole")
|
|
||||||
public ResponseResult<Void> addUserRole(
|
|
||||||
@MyRequestBody Long roleId, @MyRequestBody String userIdListString) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(roleId, userIdListString)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
Set<Long> userIdSet = Arrays.stream(
|
|
||||||
userIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (!sysRoleService.existId(roleId)
|
|
||||||
|| !sysUserService.existUniqueKeyList("userId", userIdSet)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
List<SysUserRole> userRoleList = new LinkedList<>();
|
|
||||||
for (Long userId : userIdSet) {
|
|
||||||
SysUserRole userRole = new SysUserRole();
|
|
||||||
userRole.setRoleId(roleId);
|
|
||||||
userRole.setUserId(userId);
|
|
||||||
userRoleList.add(userRole);
|
|
||||||
}
|
|
||||||
sysRoleService.addUserRoleList(userRoleList);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为指定用户移除指定角色。
|
|
||||||
*
|
|
||||||
* @param roleId 指定角色主键Id。
|
|
||||||
* @param userId 指定用户主键Id。
|
|
||||||
* @return 应答数据结果。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE_M2M)
|
|
||||||
@PostMapping("/deleteUserRole")
|
|
||||||
public ResponseResult<Void> deleteUserRole(
|
|
||||||
@MyRequestBody Long roleId, @MyRequestBody Long userId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(roleId, userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysRoleService.removeUserRole(roleId, userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以字典形式返回全部角色管理数据集合。字典的键值为[roleId, roleName]。
|
|
||||||
* 白名单接口,登录用户均可访问。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDict")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict(SysRole filter) {
|
|
||||||
List<SysRole> resultList = sysRoleService.getListByFilter(filter);
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"roleId as id", "roleName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典Id集合,获取查询后的字典数据。
|
|
||||||
*
|
|
||||||
* @param dictIds 字典Id集合。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDictByIds")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByIds(
|
|
||||||
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
|
|
||||||
List<SysRole> resultList = sysRoleService.getInList(new HashSet<>(dictIds));
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"roleId as id", "roleName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询角色的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param roleId 角色Id。
|
|
||||||
* @param url url过滤条件。
|
|
||||||
* @return 应答对象,包含从角色到权限资源的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysPermWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysPermByWithDetail(Long roleId, String url) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(roleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysRoleService.getSysPermListWithDetail(roleId, url));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询角色的权限字列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param roleId 角色Id。
|
|
||||||
* @param permCode 权限字名称过滤条件。
|
|
||||||
* @return 应答对象,包含从角色到权限字的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysPermCodeWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysPermCodeWithDetail(Long roleId, String permCode) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(roleId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysRoleService.getSysPermCodeListWithDetail(roleId, permCode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,359 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.controller;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import com.orangeforms.common.core.upload.BaseUpDownloader;
|
|
||||||
import com.orangeforms.common.core.upload.UpDownloaderFactory;
|
|
||||||
import com.orangeforms.common.core.upload.UploadResponseInfo;
|
|
||||||
import com.orangeforms.common.core.upload.UploadStoreInfo;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.*;
|
|
||||||
import com.orangeforms.webadmin.upms.dto.*;
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.webadmin.upms.service.*;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.constant.*;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.redis.cache.SessionCacheHelper;
|
|
||||||
import com.orangeforms.webadmin.config.ApplicationConfig;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户管理操作控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Api(tags = "用户管理管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/upms/sysUser")
|
|
||||||
public class SysUserController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserService sysUserService;
|
|
||||||
@Autowired
|
|
||||||
private PasswordEncoder passwordEncoder;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig appConfig;
|
|
||||||
@Autowired
|
|
||||||
private SessionCacheHelper cacheHelper;
|
|
||||||
@Autowired
|
|
||||||
private UpDownloaderFactory upDownloaderFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增用户操作。
|
|
||||||
*
|
|
||||||
* @param sysUserDto 新增用户对象。
|
|
||||||
* @param dataPermIdListString 逗号分隔的数据权限Id列表。
|
|
||||||
* @param roleIdListString 逗号分隔的角色Id列表。
|
|
||||||
* @return 应答结果对象,包含新增用户的主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"sysUserDto.userId",
|
|
||||||
"sysUserDto.createTimeStart",
|
|
||||||
"sysUserDto.createTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(
|
|
||||||
@MyRequestBody SysUserDto sysUserDto,
|
|
||||||
@MyRequestBody String dataPermIdListString,
|
|
||||||
@MyRequestBody String roleIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysUserDto, false);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysUser sysUser = MyModelUtil.copyTo(sysUserDto, SysUser.class);
|
|
||||||
CallResult result = sysUserService.verifyRelatedData(
|
|
||||||
sysUser, null, roleIdListString, dataPermIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>() {});
|
|
||||||
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>() {});
|
|
||||||
sysUserService.saveNew(sysUser, roleIdSet, dataPermIdSet);
|
|
||||||
return ResponseResult.success(sysUser.getUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户操作。
|
|
||||||
*
|
|
||||||
* @param sysUserDto 更新用户对象。
|
|
||||||
* @param dataPermIdListString 逗号分隔的数据权限Id列表。
|
|
||||||
* @param roleIdListString 逗号分隔的角色Id列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"sysUserDto.createTimeStart",
|
|
||||||
"sysUserDto.createTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(
|
|
||||||
@MyRequestBody SysUserDto sysUserDto,
|
|
||||||
@MyRequestBody String dataPermIdListString,
|
|
||||||
@MyRequestBody String roleIdListString) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(sysUserDto, true);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
SysUser originalUser = sysUserService.getById(sysUserDto.getUserId());
|
|
||||||
if (originalUser == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysUser sysUser = MyModelUtil.copyTo(sysUserDto, SysUser.class);
|
|
||||||
CallResult result = sysUserService.verifyRelatedData(
|
|
||||||
sysUser, originalUser, roleIdListString, dataPermIdListString);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
|
||||||
}
|
|
||||||
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>() {});
|
|
||||||
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>() {});
|
|
||||||
if (!sysUserService.update(sysUser, originalUser, roleIdSet, dataPermIdSet)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重置密码操作。
|
|
||||||
*
|
|
||||||
* @param userId 指定用户主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@PostMapping("/resetPassword")
|
|
||||||
public ResponseResult<Void> resetPassword(@MyRequestBody Long userId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!sysUserService.changePassword(userId, appConfig.getDefaultUserPassword())) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除用户管理数据。
|
|
||||||
*
|
|
||||||
* @param userId 删除对象主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long userId) {
|
|
||||||
String errorMessage;
|
|
||||||
if (MyCommonUtil.existBlankArgument(userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return this.doDelete(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出符合过滤条件的用户管理列表。
|
|
||||||
*
|
|
||||||
* @param sysUserDtoFilter 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含查询结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<SysUserVo>> list(
|
|
||||||
@MyRequestBody SysUserDto sysUserDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
SysUser sysUserFilter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
|
||||||
List<SysUser> sysUserList = sysUserService.getSysUserListWithRelation(sysUserFilter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(sysUserList, SysUser.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定用户管理对象详情。
|
|
||||||
*
|
|
||||||
* @param userId 指定对象主键Id。
|
|
||||||
* @return 应答结果对象,包含对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<SysUserVo> view(@RequestParam Long userId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
// 这里查看用户数据时候,需要把用户多对多关联的角色和数据权限Id一并查出。
|
|
||||||
SysUser sysUser = sysUserService.getByIdWithRelation(userId, MyRelationParam.full());
|
|
||||||
if (sysUser == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
SysUserVo sysUserVo = SysUser.INSTANCE.fromModel(sysUser);
|
|
||||||
return ResponseResult.success(sysUserVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 附件文件下载。
|
|
||||||
* 这里将图片和其他类型的附件文件放到不同的父目录下,主要为了便于今后图片文件的迁移。
|
|
||||||
*
|
|
||||||
* @param userId 附件所在记录的主键Id。
|
|
||||||
* @param fieldName 附件所属的字段名。
|
|
||||||
* @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。
|
|
||||||
* @param asImage 下载文件是否为图片。
|
|
||||||
* @param response Http 应答对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false)
|
|
||||||
@GetMapping("/download")
|
|
||||||
public void download(
|
|
||||||
@RequestParam(required = false) Long userId,
|
|
||||||
@RequestParam String fieldName,
|
|
||||||
@RequestParam String filename,
|
|
||||||
@RequestParam Boolean asImage,
|
|
||||||
HttpServletResponse response) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。
|
|
||||||
// 否则有可能给前端返回的是200的错误码。
|
|
||||||
try {
|
|
||||||
// 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。
|
|
||||||
if (userId == null) {
|
|
||||||
if (!cacheHelper.existSessionUploadFile(filename)) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SysUser sysUser = sysUserService.getById(userId);
|
|
||||||
if (sysUser == null) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String fieldJsonData = (String) ReflectUtil.getFieldValue(sysUser, fieldName);
|
|
||||||
if (fieldJsonData == null) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!BaseUpDownloader.containFile(fieldJsonData, filename)) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, fieldName);
|
|
||||||
if (!storeInfo.isSupportUpload()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_NOT_IMPLEMENTED,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
|
||||||
upDownloader.doDownload(appConfig.getUploadFileBaseDir(),
|
|
||||||
SysUser.class.getSimpleName(), fieldName, filename, asImage, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传操作。
|
|
||||||
*
|
|
||||||
* @param fieldName 上传文件名。
|
|
||||||
* @param asImage 是否作为图片上传。如果是图片,今后下载的时候无需权限验证。否则就是附件上传,下载时需要权限验证。
|
|
||||||
* @param uploadFile 上传文件对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false)
|
|
||||||
@PostMapping("/upload")
|
|
||||||
public void upload(
|
|
||||||
@RequestParam String fieldName,
|
|
||||||
@RequestParam Boolean asImage,
|
|
||||||
@RequestParam("uploadFile") MultipartFile uploadFile) throws Exception {
|
|
||||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, fieldName);
|
|
||||||
// 这里就会判断参数中指定的字段,是否支持上传操作。
|
|
||||||
if (!storeInfo.isSupportUpload()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 根据字段注解中的存储类型,通过工厂方法获取匹配的上传下载实现类,从而解耦。
|
|
||||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
|
||||||
UploadResponseInfo responseInfo = upDownloader.doUpload(null,
|
|
||||||
appConfig.getUploadFileBaseDir(), SysUser.class.getSimpleName(), fieldName, asImage, uploadFile);
|
|
||||||
if (responseInfo.getUploadFailed()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cacheHelper.putSessionUploadFile(responseInfo.getFilename());
|
|
||||||
ResponseResult.output(ResponseResult.success(responseInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param url url过滤条件。
|
|
||||||
* @return 应答对象,包含从用户到权限资源的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysPermWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysPermWithDetail(Long userId, String url) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysUserService.getSysPermListWithDetail(userId, url));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的权限字列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param permCode 权限字名称过滤条件。
|
|
||||||
* @return 应答对象,包含从用户到权限字的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysPermCodeWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysPermCodeWithDetail(Long userId, String permCode) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysUserService.getSysPermCodeListWithDetail(userId, permCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param menuName 菜单名称过滤条件。
|
|
||||||
* @return 应答对象,包含从用户到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listSysMenuWithDetail")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listSysMenuWithDetail(Long userId, String menuName) {
|
|
||||||
if (MyCommonUtil.isBlankOrNull(userId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success(sysUserService.getSysMenuListWithDetail(userId, menuName));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doDelete(Long userId) {
|
|
||||||
String errorMessage;
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
SysUser originalSysUser = sysUserService.getById(userId);
|
|
||||||
if (originalSysUser == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
if (!sysUserService.remove(userId)) {
|
|
||||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysDataPermDept;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限与部门关系数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDataPermDeptMapper extends BaseDaoMapper<SysDataPermDept> {
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysDataPerm;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限数据访问操作接口。
|
|
||||||
* NOTE: 该对象一定不能被 @EnableDataPerm 注解标注,否则会导致无限递归。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDataPermMapper extends BaseDaoMapper<SysDataPerm> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据权限列表。
|
|
||||||
*
|
|
||||||
* @param sysDataPermFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串。
|
|
||||||
* @return 过滤后的数据权限列表。
|
|
||||||
*/
|
|
||||||
List<SysDataPerm> getSysDataPermList(
|
|
||||||
@Param("sysDataPermFilter") SysDataPerm sysDataPermFilter, @Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户的数据权限列表。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @return 数据权限列表。
|
|
||||||
*/
|
|
||||||
List<SysDataPerm> getSysDataPermListByUserId(@Param("userId") Long userId);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysDataPermUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限与用户关系数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDataPermUserMapper extends BaseDaoMapper<SysDataPermUser> {
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysDept;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门管理数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDeptMapper extends BaseDaoMapper<SysDept> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param sysDeptList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<SysDept> sysDeptList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取过滤后的对象列表。
|
|
||||||
*
|
|
||||||
* @param sysDeptFilter 主表过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
List<SysDept> getSysDeptList(
|
|
||||||
@Param("sysDeptFilter") SysDept sysDeptFilter, @Param("orderBy") String orderBy);
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysDeptRelation;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门关系树关联关系表访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDeptRelationMapper extends BaseDaoMapper<SysDeptRelation> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将myDeptId的所有子部门,与其父部门parentDeptId解除关联关系。
|
|
||||||
*
|
|
||||||
* @param parentDeptId myDeptId的父部门Id。
|
|
||||||
* @param myDeptId 当前部门。
|
|
||||||
*/
|
|
||||||
void removeBetweenChildrenAndParents(
|
|
||||||
@Param("parentDeptId") Long parentDeptId, @Param("myDeptId") Long myDeptId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入部门关联数据。
|
|
||||||
* 由于目前版本(3.4.1)的Mybatis Plus没有提供真正的批量插入,为了保证效率需要自己实现。
|
|
||||||
* 目前我们仅仅给出MySQL和PostgresSQL的insert list实现作为参考,其他数据库需要自行修改。
|
|
||||||
*
|
|
||||||
* @param deptRelationList 部门关联关系数据列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<SysDeptRelation> deptRelationList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入当前部门的所有父部门列表,包括自己和自己的关系。
|
|
||||||
*
|
|
||||||
* @param parentDeptId myDeptId的父部门Id。
|
|
||||||
* @param myDeptId 当前部门。
|
|
||||||
*/
|
|
||||||
void insertParentList(@Param("parentDeptId") Long parentDeptId, @Param("myDeptId") Long myDeptId);
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenu;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysMenuMapper extends BaseDaoMapper<SysMenu> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录用户的菜单列表。
|
|
||||||
*
|
|
||||||
* @param userId 登录用户。
|
|
||||||
* @return 菜单列表。
|
|
||||||
*/
|
|
||||||
List<SysMenu> getMenuListByUserId(@Param("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前用户有权访问的在线表单菜单,仅返回类型为BUTTON的菜单。
|
|
||||||
*
|
|
||||||
* @param userId 指定的用户。
|
|
||||||
* @param menuType 菜单类型,NULL则返回全部类型。
|
|
||||||
* @return 在线表单关联的菜单列表。
|
|
||||||
*/
|
|
||||||
List<SysMenu> getOnlineMenuListByUserId(
|
|
||||||
@Param("userId") Long userId, @Param("menuType") Integer menuType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param url 权限资源地址过滤条件。
|
|
||||||
* @return 包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermListWithDetail(
|
|
||||||
@Param("menuId") Long menuId, @Param("url") String url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysUserListWithDetail(
|
|
||||||
@Param("menuId") Long menuId, @Param("loginName") String loginName);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenuPermCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单与权限字关系数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysMenuPermCodeMapper extends BaseDaoMapper<SysMenuPermCode> {
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCode;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermCodeMapper extends BaseDaoMapper<SysPermCode> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户的所有权限字列表。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @return 该用户的权限字列表。
|
|
||||||
*/
|
|
||||||
List<String> getPermCodeListByUserId(@Param("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysUserListWithDetail(
|
|
||||||
@Param("permCodeId") Long permCodeId, @Param("loginName") String loginName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 包含从权限字到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysRoleListWithDetail(
|
|
||||||
@Param("permCodeId") Long permCodeId, @Param("roleName") String roleName);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCodePerm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字与权限资源关系数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermCodePermMapper extends BaseDaoMapper<SysPermCodePerm> {
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPerm;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermMapper extends BaseDaoMapper<SysPerm> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户的权限列表。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @return 该用户的权限标识列表。
|
|
||||||
*/
|
|
||||||
List<String> getPermListByUserId(@Param("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysUserListWithDetail(
|
|
||||||
@Param("permId") Long permId, @Param("loginName") String loginName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysRoleListWithDetail(
|
|
||||||
@Param("permId") Long permId, @Param("roleName") String roleName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param menuName 菜单名。
|
|
||||||
* @return 包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysMenuListWithDetail(
|
|
||||||
@Param("permId") Long permId, @Param("menuName") String menuName);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermModule;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源模块数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermModuleMapper extends BaseDaoMapper<SysPermModule> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取整个权限模块和权限关联后的全部数据。
|
|
||||||
*
|
|
||||||
* @return 关联的权限模块和权限资源列表。
|
|
||||||
*/
|
|
||||||
List<SysPermModule> getPermModuleAndPermList();
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermWhitelist;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源白名单数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermWhitelistMapper extends BaseDaoMapper<SysPermWhitelist> {
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysRole;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysRoleMapper extends BaseDaoMapper<SysRole> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象列表,过滤条件中包含like和between条件。
|
|
||||||
*
|
|
||||||
* @param sysRoleFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
List<SysRole> getSysRoleList(@Param("sysRoleFilter") SysRole sysRoleFilter, @Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询角色的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param roleId 角色Id。
|
|
||||||
* @param url url过滤条件。
|
|
||||||
* @return 包含从角色到权限资源的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermListWithDetail(
|
|
||||||
@Param("roleId") Long roleId, @Param("url") String url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询角色的权限字列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param roleId 角色Id。
|
|
||||||
* @param permCode 权限字名称过滤条件。
|
|
||||||
* @return 包含从角色到权限字的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermCodeListWithDetail(
|
|
||||||
@Param("roleId") Long roleId, @Param("permCode") String permCode);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysRoleMenu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色与菜单操作关联关系数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysRoleMenuMapper extends BaseDaoMapper<SysRoleMenu> {
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysUser;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户管理数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysUserMapper extends BaseDaoMapper<SysUser> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param sysUserList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<SysUser> sysUserList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取过滤后的对象列表。
|
|
||||||
*
|
|
||||||
* @param sysUserFilter 主表过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserList(
|
|
||||||
@Param("sysUserFilter") SysUser sysUserFilter, @Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据角色Id,获取关联的用户Id列表。
|
|
||||||
*
|
|
||||||
* @param roleId 关联的角色Id。
|
|
||||||
* @param sysUserFilter 用户过滤条件对象。
|
|
||||||
* @param orderBy order by从句的参数。
|
|
||||||
* @return 和RoleId关联的用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserListByRoleId(
|
|
||||||
@Param("roleId") Long roleId,
|
|
||||||
@Param("sysUserFilter") SysUser sysUserFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据角色Id,获取和当前角色Id没有建立多对多关联关系的用户Id列表。
|
|
||||||
*
|
|
||||||
* @param roleId 关联的角色Id。
|
|
||||||
* @param sysUserFilter 用户过滤条件对象。
|
|
||||||
* @param orderBy order by从句的参数。
|
|
||||||
* @return 和RoleId没有建立关联关系的用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getNotInSysUserListByRoleId(
|
|
||||||
@Param("roleId") Long roleId,
|
|
||||||
@Param("sysUserFilter") SysUser sysUserFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数据权限Id,获取关联的用户Id列表。
|
|
||||||
*
|
|
||||||
* @param dataPermId 关联的数据权限Id。
|
|
||||||
* @param sysUserFilter 用户过滤条件对象。
|
|
||||||
* @param orderBy order by从句的参数。
|
|
||||||
* @return 和DataPermId关联的用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserListByDataPermId(
|
|
||||||
@Param("dataPermId") Long dataPermId,
|
|
||||||
@Param("sysUserFilter") SysUser sysUserFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数据权限Id,获取和当前数据权限Id没有建立多对多关联关系的用户Id列表。
|
|
||||||
*
|
|
||||||
* @param dataPermId 关联的数据权限Id。
|
|
||||||
* @param sysUserFilter 用户过滤条件对象。
|
|
||||||
* @param orderBy order by从句的参数。
|
|
||||||
* @return 和DataPermId没有建立关联关系的用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getNotInSysUserListByDataPermId(
|
|
||||||
@Param("dataPermId") Long dataPermId,
|
|
||||||
@Param("sysUserFilter") SysUser sysUserFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param url url过滤条件。
|
|
||||||
* @return 包含从用户到权限资源的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermListWithDetail(
|
|
||||||
@Param("userId") Long userId, @Param("url") String url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的权限字列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param permCode 权限字名称过滤条件。
|
|
||||||
* @return 包含从用户到权限字的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermCodeListWithDetail(
|
|
||||||
@Param("userId") Long userId, @Param("permCode") String permCode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param menuName 菜单名称过滤条件。
|
|
||||||
* @return 包含从用户到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysMenuListWithDetail(
|
|
||||||
@Param("userId") Long userId, @Param("menuName") String menuName);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysUserRole;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户与角色关联关系数据访问操作接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysUserRoleMapper extends BaseDaoMapper<SysUserRole> {
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysDataPermDeptMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysDataPermDept">
|
|
||||||
<id column="data_perm_id" jdbcType="BIGINT" property="dataPermId"/>
|
|
||||||
<id column="dept_id" jdbcType="BIGINT" property="deptId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysDataPermMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysDataPerm">
|
|
||||||
<id column="data_perm_id" jdbcType="BIGINT" property="dataPermId"/>
|
|
||||||
<result column="data_perm_name" jdbcType="VARCHAR" property="dataPermName"/>
|
|
||||||
<result column="rule_type" jdbcType="INTEGER" property="ruleType"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMapEx" type="com.orangeforms.webadmin.upms.model.SysDataPerm" extends="BaseResultMap">
|
|
||||||
<collection property="dataPermDeptList" column="data_perm_id" javaType="ArrayList"
|
|
||||||
ofType="com.orangeforms.webadmin.upms.model.SysDataPermDept" notNullColumn="dept_id"
|
|
||||||
resultMap="com.orangeforms.webadmin.upms.dao.SysDataPermDeptMapper.BaseResultMap">
|
|
||||||
</collection>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="filterRef">
|
|
||||||
<if test="sysDataPermFilter != null">
|
|
||||||
<if test="sysDataPermFilter.ruleType != null">
|
|
||||||
AND zz_sys_data_perm.rule_type = #{sysDataPermFilter.ruleType}
|
|
||||||
</if>
|
|
||||||
<if test="sysDataPermFilter.searchString != null and sysDataPermFilter.searchString != ''">
|
|
||||||
<bind name= "safeSearchString" value= "'%' + sysDataPermFilter.searchString + '%'" />
|
|
||||||
AND COALESCE(zz_sys_data_perm.data_perm_name, '') LIKE #{safeSearchString}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getSysDataPermList" resultMap="BaseResultMap" parameterType="com.orangeforms.webadmin.upms.model.SysDataPerm">
|
|
||||||
SELECT
|
|
||||||
zz_sys_data_perm.*
|
|
||||||
FROM
|
|
||||||
zz_sys_data_perm
|
|
||||||
<where>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysDataPermListByUserId" resultMap="BaseResultMapEx" parameterType="com.orangeforms.webadmin.upms.model.SysDataPerm">
|
|
||||||
SELECT
|
|
||||||
zz_sys_data_perm.*,
|
|
||||||
zz_sys_data_perm_dept.*
|
|
||||||
FROM
|
|
||||||
zz_sys_data_perm_user
|
|
||||||
INNER JOIN
|
|
||||||
zz_sys_data_perm ON zz_sys_data_perm_user.data_perm_id = zz_sys_data_perm.data_perm_id
|
|
||||||
LEFT JOIN
|
|
||||||
zz_sys_data_perm_dept ON zz_sys_data_perm.data_perm_id = zz_sys_data_perm_dept.data_perm_id
|
|
||||||
<where>
|
|
||||||
AND zz_sys_data_perm_user.user_id = #{userId}
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysDataPermUserMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysDataPermUser">
|
|
||||||
<id column="data_perm_id" jdbcType="BIGINT" property="dataPermId"/>
|
|
||||||
<id column="user_id" jdbcType="BIGINT" property="userId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysDeptMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysDept">
|
|
||||||
<id column="dept_id" jdbcType="BIGINT" property="deptId"/>
|
|
||||||
<result column="dept_name" jdbcType="VARCHAR" property="deptName"/>
|
|
||||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
|
||||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
|
||||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_sys_dept
|
|
||||||
(dept_id,
|
|
||||||
dept_name,
|
|
||||||
show_order,
|
|
||||||
parent_id,
|
|
||||||
deleted_flag,
|
|
||||||
create_user_id,
|
|
||||||
update_user_id,
|
|
||||||
create_time,
|
|
||||||
update_time)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.deptId},
|
|
||||||
#{item.deptName},
|
|
||||||
#{item.showOrder},
|
|
||||||
#{item.parentId},
|
|
||||||
#{item.deletedFlag},
|
|
||||||
#{item.createUserId},
|
|
||||||
#{item.updateUserId},
|
|
||||||
#{item.createTime},
|
|
||||||
#{item.updateTime})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
|
||||||
<sql id="filterRef">
|
|
||||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
|
||||||
<include refid="com.orangeforms.webadmin.upms.dao.SysDeptMapper.inputFilterRef"/>
|
|
||||||
AND zz_sys_dept.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
|
||||||
<sql id="inputFilterRef">
|
|
||||||
<if test="sysDeptFilter != null">
|
|
||||||
<if test="sysDeptFilter.deptName != null and sysDeptFilter.deptName != ''">
|
|
||||||
<bind name = "safeSysDeptDeptName" value = "'%' + sysDeptFilter.deptName + '%'" />
|
|
||||||
AND zz_sys_dept.dept_name LIKE #{safeSysDeptDeptName}
|
|
||||||
</if>
|
|
||||||
<if test="sysDeptFilter.parentId != null">
|
|
||||||
AND zz_sys_dept.parent_id = #{sysDeptFilter.parentId}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getSysDeptList" resultMap="BaseResultMap" parameterType="com.orangeforms.webadmin.upms.model.SysDept">
|
|
||||||
SELECT * FROM zz_sys_dept
|
|
||||||
<where>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysDeptRelationMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysDeptRelation">
|
|
||||||
<id column="parent_dept_id" jdbcType="BIGINT" property="parentDeptId"/>
|
|
||||||
<id column="dept_id" jdbcType="BIGINT" property="deptId"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<delete id="removeBetweenChildrenAndParents">
|
|
||||||
DELETE a FROM zz_sys_dept_relation a
|
|
||||||
INNER JOIN zz_sys_dept_relation b ON a.dept_id = b.dept_id
|
|
||||||
WHERE a.parent_dept_id = #{parentDeptId} AND b.parent_dept_id = #{myDeptId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_sys_dept_relation(parent_dept_id, dept_id) VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator=",">
|
|
||||||
(#{item.parentDeptId}, #{item.deptId})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<insert id="insertParentList">
|
|
||||||
INSERT INTO zz_sys_dept_relation(parent_dept_id, dept_id)
|
|
||||||
SELECT t.parent_dept_id, #{myDeptId} FROM zz_sys_dept_relation t
|
|
||||||
WHERE t.dept_id = #{parentDeptId}
|
|
||||||
UNION ALL
|
|
||||||
SELECT #{myDeptId}, #{myDeptId}
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysMenuMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysMenu">
|
|
||||||
<id column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
|
||||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
|
||||||
<result column="menu_name" jdbcType="VARCHAR" property="menuName"/>
|
|
||||||
<result column="menu_type" jdbcType="INTEGER" property="menuType"/>
|
|
||||||
<result column="form_router_name" jdbcType="VARCHAR" property="formRouterName"/>
|
|
||||||
<result column="online_form_id" jdbcType="BIGINT" property="onlineFormId"/>
|
|
||||||
<result column="online_menu_perm_type" jdbcType="INTEGER" property="onlineMenuPermType"/>
|
|
||||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
|
||||||
<result column="icon" jdbcType="VARCHAR" property="icon"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="getMenuListByUserId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
m.*
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
AND m.menu_type <= ${@com.orangeforms.webadmin.upms.model.constant.SysMenuType@TYPE_MENU}
|
|
||||||
</where>
|
|
||||||
ORDER BY m.show_order
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getOnlineMenuListByUserId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
m.*
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
AND m.online_form_id IS NOT NULL
|
|
||||||
<if test="menuType != null">
|
|
||||||
AND m.menu_type = #{menuType}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY m.show_order
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 以下查询仅用于权限分配的问题定位,由于关联表较多,可能会给系统运行带来性能影响 -->
|
|
||||||
<select id="getSysPermListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.show_name "showName",
|
|
||||||
pc.perm_code_type "permCodeType",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
p.perm_id "permId",
|
|
||||||
p.perm_name "permName",
|
|
||||||
p.url
|
|
||||||
FROM
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm_code pc,
|
|
||||||
zz_sys_perm p
|
|
||||||
<where>
|
|
||||||
AND mpc.menu_id = #{menuId}
|
|
||||||
AND mpc.perm_code_id = pc.perm_code_id
|
|
||||||
AND mpc.perm_code_id = pcp.perm_code_id
|
|
||||||
AND pcp.perm_id = p.perm_id
|
|
||||||
<if test="url != null and url != ''">
|
|
||||||
AND p.url = #{url}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
pc.perm_code_id, p.url
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysUserListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
u.user_id "userId",
|
|
||||||
u.login_name "loginName",
|
|
||||||
u.show_name "showName",
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName"
|
|
||||||
FROM
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_role r,
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_user u
|
|
||||||
<where>
|
|
||||||
AND rm.menu_id = #{menuId}
|
|
||||||
AND rm.role_id = r.role_id
|
|
||||||
AND rm.role_id = ur.role_id
|
|
||||||
AND ur.user_id = u.user_id
|
|
||||||
<if test="loginName != null and loginName != ''">
|
|
||||||
AND u.login_name = #{loginName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
u.user_id, r.role_id
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysMenuPermCodeMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysMenuPermCode">
|
|
||||||
<id column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
|
||||||
<id column="perm_code_id" jdbcType="BIGINT" property="permCodeId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysPermCodeMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysPermCode">
|
|
||||||
<id column="perm_code_id" jdbcType="BIGINT" property="permCodeId"/>
|
|
||||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
|
||||||
<result column="perm_code" jdbcType="VARCHAR" property="permCode"/>
|
|
||||||
<result column="perm_code_type" jdbcType="INTEGER" property="permCodeType"/>
|
|
||||||
<result column="show_name" jdbcType="VARCHAR" property="showName"/>
|
|
||||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="getPermCodeListByUserId" resultType="java.lang.String">
|
|
||||||
SELECT
|
|
||||||
pc.perm_code
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code pc
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = mpc.menu_id
|
|
||||||
AND mpc.perm_code_id = pc.perm_code_id
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 以下查询仅用于权限分配的问题定位,由于关联表较多,可能会给系统运行带来性能影响 -->
|
|
||||||
<select id="getSysUserListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
u.user_id "userId",
|
|
||||||
u.login_name "loginName",
|
|
||||||
u.show_name "showName",
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType"
|
|
||||||
FROM
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_role r,
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_user u
|
|
||||||
<where>
|
|
||||||
AND mpc.perm_code_id = #{permCodeId}
|
|
||||||
AND mpc.menu_id = m.menu_id
|
|
||||||
AND mpc.menu_id = rm.menu_id
|
|
||||||
AND rm.role_id = r.role_id
|
|
||||||
AND rm.role_id = ur.role_id
|
|
||||||
AND ur.user_id = u.user_id
|
|
||||||
<if test="loginName != null and loginName != ''">
|
|
||||||
AND u.login_name = #{loginName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
u.user_id, r.role_id, m.menu_id
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysRoleListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType"
|
|
||||||
FROM
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_role r
|
|
||||||
<where>
|
|
||||||
AND mpc.perm_code_id = #{permCodeId}
|
|
||||||
AND mpc.menu_id = m.menu_id
|
|
||||||
AND mpc.menu_id = rm.menu_id
|
|
||||||
AND rm.role_id = r.role_id
|
|
||||||
<if test="roleName != null and roleName != ''">
|
|
||||||
AND r.role_name = #{roleName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
r.role_id, m.menu_id
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysPermCodePermMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysPermCodePerm">
|
|
||||||
<id column="perm_code_id" jdbcType="BIGINT" property="permCodeId"/>
|
|
||||||
<id column="perm_id" jdbcType="BIGINT" property="permId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysPermMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysPerm">
|
|
||||||
<id column="perm_id" jdbcType="BIGINT" property="permId"/>
|
|
||||||
<result column="module_id" jdbcType="BIGINT" property="moduleId"/>
|
|
||||||
<result column="perm_name" jdbcType="VARCHAR" property="permName"/>
|
|
||||||
<result column="url" jdbcType="VARCHAR" property="url"/>
|
|
||||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="getPermListByUserId" resultType="java.lang.String">
|
|
||||||
SELECT
|
|
||||||
p.url
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm p
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = mpc.menu_id
|
|
||||||
AND mpc.perm_code_id = pcp.perm_code_id
|
|
||||||
AND pcp.perm_id = p.perm_id
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 以下查询仅用于权限分配的问题定位,由于关联表较多,可能会给系统运行带来性能影响 -->
|
|
||||||
<select id="getSysUserListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
u.user_id "userId",
|
|
||||||
u.login_name "loginName",
|
|
||||||
u.show_name "showName",
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType"
|
|
||||||
FROM
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm_code pc,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_role r,
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_user u
|
|
||||||
<where>
|
|
||||||
AND pcp.perm_id = #{permId}
|
|
||||||
AND pcp.perm_code_id = pc.perm_code_id
|
|
||||||
AND pcp.perm_code_id = mpc.perm_code_id
|
|
||||||
AND mpc.menu_id = m.menu_id
|
|
||||||
AND mpc.menu_id = rm.menu_id
|
|
||||||
AND rm.role_id = r.role_id
|
|
||||||
AND rm.role_id = ur.role_id
|
|
||||||
AND ur.user_id = u.user_id
|
|
||||||
<if test="loginName != null and loginName != ''">
|
|
||||||
AND u.login_name = #{loginName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
u.user_id, r.role_id, m.menu_id, pc.perm_code_id
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysRoleListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType"
|
|
||||||
FROM
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm_code pc,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_role r
|
|
||||||
<where>
|
|
||||||
AND pcp.perm_id = #{permId}
|
|
||||||
AND pcp.perm_code_id = pc.perm_code_id
|
|
||||||
AND pcp.perm_code_id = mpc.perm_code_id
|
|
||||||
AND mpc.menu_id = m.menu_id
|
|
||||||
AND mpc.menu_id = rm.menu_id
|
|
||||||
AND rm.role_id = r.role_id
|
|
||||||
<if test="roleName != null and roleName != ''">
|
|
||||||
AND r.role_name = #{roleName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
r.role_id, m.menu_id, pc.perm_code_id
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysMenuListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType"
|
|
||||||
FROM
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm_code pc,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_menu m
|
|
||||||
<where>
|
|
||||||
AND pcp.perm_id = #{permId}
|
|
||||||
AND pcp.perm_code_id = pc.perm_code_id
|
|
||||||
AND pcp.perm_code_id = mpc.perm_code_id
|
|
||||||
AND mpc.menu_id = m.menu_id
|
|
||||||
<if test="menuName != null and menuName != ''">
|
|
||||||
AND m.menu_name = #{menuName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
m.menu_id, pc.perm_code_id
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysPermModuleMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysPermModule">
|
|
||||||
<id column="module_id" jdbcType="BIGINT" property="moduleId"/>
|
|
||||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
|
||||||
<result column="module_name" jdbcType="VARCHAR" property="moduleName"/>
|
|
||||||
<result column="module_type" jdbcType="INTEGER" property="moduleType"/>
|
|
||||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMapEx" type="com.orangeforms.webadmin.upms.model.SysPermModule" extends="BaseResultMap">
|
|
||||||
<collection property="sysPermList" column="module_id" javaType="ArrayList"
|
|
||||||
ofType="com.orangeforms.webadmin.upms.model.SysPerm" notNullColumn="perm_id"
|
|
||||||
resultMap="com.orangeforms.webadmin.upms.dao.SysPermMapper.BaseResultMap">
|
|
||||||
</collection>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<select id="getPermModuleAndPermList" resultMap="BaseResultMapEx">
|
|
||||||
SELECT
|
|
||||||
pm.module_id,
|
|
||||||
pm.module_name,
|
|
||||||
pm.parent_id,
|
|
||||||
pm.module_type,
|
|
||||||
p.perm_id,
|
|
||||||
p.perm_name,
|
|
||||||
p.module_id,
|
|
||||||
p.url
|
|
||||||
FROM
|
|
||||||
zz_sys_perm_module pm
|
|
||||||
LEFT JOIN
|
|
||||||
zz_sys_perm p ON pm.module_id = p.module_id
|
|
||||||
ORDER BY
|
|
||||||
pm.show_order, p.show_order
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysPermWhitelistMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysPermWhitelist">
|
|
||||||
<id column="perm_url" jdbcType="VARCHAR" property="permUrl"/>
|
|
||||||
<result column="module_name" jdbcType="VARCHAR" property="moduleName"/>
|
|
||||||
<result column="perm_name" jdbcType="VARCHAR" property="permName"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysRoleMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysRole">
|
|
||||||
<id column="role_id" jdbcType="BIGINT" property="roleId"/>
|
|
||||||
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="filterRef">
|
|
||||||
<if test="sysRoleFilter != null">
|
|
||||||
<if test="sysRoleFilter.roleName != null and sysRoleFilter.roleName != ''">
|
|
||||||
<bind name= "safeRoleName" value= "'%' + sysRoleFilter.roleName + '%'"/>
|
|
||||||
AND role_name LIKE #{safeRoleName}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getSysRoleList" resultMap="BaseResultMap" parameterType="com.orangeforms.webadmin.upms.model.SysRole">
|
|
||||||
SELECT * FROM zz_sys_role
|
|
||||||
<where>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 以下查询仅用于权限分配的问题定位,由于关联表较多,可能会给系统运行带来性能影响 -->
|
|
||||||
<select id="getSysPermListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType",
|
|
||||||
p.url
|
|
||||||
FROM
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code pc,
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm p
|
|
||||||
<where>
|
|
||||||
AND rm.role_id = #{roleId}
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
AND rm.menu_id = mpc.menu_id
|
|
||||||
AND mpc.perm_code_id = pc.perm_code_id
|
|
||||||
AND mpc.perm_code_id = pcp.perm_code_id
|
|
||||||
AND pcp.perm_id = p.perm_id
|
|
||||||
<if test="url != null and url != ''">
|
|
||||||
AND p.url = #{url}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
m.menu_id, pc.perm_code_id, p.url
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysPermCodeListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType"
|
|
||||||
FROM
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code pc
|
|
||||||
<where>
|
|
||||||
AND rm.role_id = #{roleId}
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
AND rm.menu_id = mpc.menu_id
|
|
||||||
AND mpc.perm_code_id = pc.perm_code_id
|
|
||||||
<if test="permCode != null and permCode != ''">
|
|
||||||
AND pc.perm_code = #{permCode}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
m.menu_id, pc.perm_code_id
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysRoleMenuMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysRoleMenu">
|
|
||||||
<id column="role_id" jdbcType="BIGINT" property="roleId"/>
|
|
||||||
<id column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysUserMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysUser">
|
|
||||||
<id column="user_id" jdbcType="BIGINT" property="userId"/>
|
|
||||||
<result column="login_name" jdbcType="VARCHAR" property="loginName"/>
|
|
||||||
<result column="password" jdbcType="VARCHAR" property="password"/>
|
|
||||||
<result column="show_name" jdbcType="VARCHAR" property="showName"/>
|
|
||||||
<result column="dept_id" jdbcType="BIGINT" property="deptId"/>
|
|
||||||
<result column="user_type" jdbcType="INTEGER" property="userType"/>
|
|
||||||
<result column="head_image_url" jdbcType="VARCHAR" property="headImageUrl"/>
|
|
||||||
<result column="user_status" jdbcType="INTEGER" property="userStatus"/>
|
|
||||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_sys_user
|
|
||||||
(user_id,
|
|
||||||
login_name,
|
|
||||||
password,
|
|
||||||
show_name,
|
|
||||||
dept_id,
|
|
||||||
user_type,
|
|
||||||
head_image_url,
|
|
||||||
user_status,
|
|
||||||
deleted_flag,
|
|
||||||
create_user_id,
|
|
||||||
update_user_id,
|
|
||||||
create_time,
|
|
||||||
update_time)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.userId},
|
|
||||||
#{item.loginName},
|
|
||||||
#{item.password},
|
|
||||||
#{item.showName},
|
|
||||||
#{item.deptId},
|
|
||||||
#{item.userType},
|
|
||||||
#{item.headImageUrl},
|
|
||||||
#{item.userStatus},
|
|
||||||
#{item.deletedFlag},
|
|
||||||
#{item.createUserId},
|
|
||||||
#{item.updateUserId},
|
|
||||||
#{item.createTime},
|
|
||||||
#{item.updateTime})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
|
||||||
<sql id="filterRef">
|
|
||||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
|
||||||
<include refid="com.orangeforms.webadmin.upms.dao.SysUserMapper.inputFilterRef"/>
|
|
||||||
AND zz_sys_user.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
|
||||||
<sql id="inputFilterRef">
|
|
||||||
<if test="sysUserFilter != null">
|
|
||||||
<if test="sysUserFilter.loginName != null and sysUserFilter.loginName != ''">
|
|
||||||
<bind name = "safeSysUserLoginName" value = "'%' + sysUserFilter.loginName + '%'" />
|
|
||||||
AND zz_sys_user.login_name LIKE #{safeSysUserLoginName}
|
|
||||||
</if>
|
|
||||||
<if test="sysUserFilter.showName != null and sysUserFilter.showName != ''">
|
|
||||||
<bind name = "safeSysUserShowName" value = "'%' + sysUserFilter.showName + '%'" />
|
|
||||||
AND zz_sys_user.show_name LIKE #{safeSysUserShowName}
|
|
||||||
</if>
|
|
||||||
<if test="sysUserFilter.deptId != null">
|
|
||||||
AND zz_sys_user.dept_id = #{sysUserFilter.deptId}
|
|
||||||
</if>
|
|
||||||
<if test="sysUserFilter.userStatus != null">
|
|
||||||
AND zz_sys_user.user_status = #{sysUserFilter.userStatus}
|
|
||||||
</if>
|
|
||||||
<if test="sysUserFilter.createTimeStart != null and sysUserFilter.createTimeStart != ''">
|
|
||||||
AND zz_sys_user.create_time >= #{sysUserFilter.createTimeStart}
|
|
||||||
</if>
|
|
||||||
<if test="sysUserFilter.createTimeEnd != null and sysUserFilter.createTimeEnd != ''">
|
|
||||||
AND zz_sys_user.create_time <= #{sysUserFilter.createTimeEnd}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getSysUserList" resultMap="BaseResultMap" parameterType="com.orangeforms.webadmin.upms.model.SysUser">
|
|
||||||
SELECT * FROM zz_sys_user
|
|
||||||
<where>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysUserListByRoleId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
zz_sys_user.*
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role,
|
|
||||||
zz_sys_user
|
|
||||||
<where>
|
|
||||||
AND zz_sys_user_role.role_id = #{roleId}
|
|
||||||
AND zz_sys_user_role.user_id = zz_sys_user.user_id
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getNotInSysUserListByRoleId" resultMap="BaseResultMap">
|
|
||||||
SELECT * FROM zz_sys_user
|
|
||||||
<where>
|
|
||||||
NOT EXISTS (SELECT * FROM zz_sys_user_role
|
|
||||||
WHERE zz_sys_user_role.role_id = #{roleId} AND zz_sys_user_role.user_id = zz_sys_user.user_id)
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysUserListByDataPermId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
zz_sys_user.*
|
|
||||||
FROM
|
|
||||||
zz_sys_data_perm_user,
|
|
||||||
zz_sys_user
|
|
||||||
<where>
|
|
||||||
AND zz_sys_data_perm_user.data_perm_id = #{dataPermId}
|
|
||||||
AND zz_sys_data_perm_user.user_id = zz_sys_user.user_id
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getNotInSysUserListByDataPermId" resultMap="BaseResultMap">
|
|
||||||
SELECT * FROM zz_sys_user
|
|
||||||
<where>
|
|
||||||
NOT EXISTS (SELECT * FROM zz_sys_data_perm_user
|
|
||||||
WHERE zz_sys_data_perm_user.data_perm_id = #{dataPermId} AND zz_sys_data_perm_user.user_id = zz_sys_user.user_id)
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 以下查询仅用于权限分配的问题定位,由于关联表较多,可能会给系统运行带来性能影响 -->
|
|
||||||
<select id="getSysPermListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType",
|
|
||||||
p.url
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role r,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code pc,
|
|
||||||
zz_sys_perm_code_perm pcp,
|
|
||||||
zz_sys_perm p
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = r.role_id
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
AND rm.menu_id = mpc.menu_id
|
|
||||||
AND mpc.perm_code_id = pc.perm_code_id
|
|
||||||
AND mpc.perm_code_id = pcp.perm_code_id
|
|
||||||
AND pcp.perm_id = p.perm_id
|
|
||||||
<if test="url != null and url != ''">
|
|
||||||
AND p.url = #{url}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
r.role_id, m.menu_id, pc.perm_code_id, p.url
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysPermCodeListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType",
|
|
||||||
pc.perm_code_id "permCodeId",
|
|
||||||
pc.perm_code "permCode",
|
|
||||||
pc.perm_code_type "permCodeType"
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role r,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m,
|
|
||||||
zz_sys_menu_perm_code mpc,
|
|
||||||
zz_sys_perm_code pc
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = r.role_id
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
AND rm.menu_id = mpc.menu_id
|
|
||||||
AND mpc.perm_code_id = pc.perm_code_id
|
|
||||||
<if test="permCode != null and permCode != ''">
|
|
||||||
AND pc.perm_code = #{permCode}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
r.role_id, m.menu_id, pc.perm_code_id
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getSysMenuListWithDetail" resultType="map">
|
|
||||||
SELECT
|
|
||||||
r.role_id "roleId",
|
|
||||||
r.role_name "roleName",
|
|
||||||
m.menu_id "menuId",
|
|
||||||
m.menu_name "menuName",
|
|
||||||
m.menu_type "menuType"
|
|
||||||
FROM
|
|
||||||
zz_sys_user_role ur,
|
|
||||||
zz_sys_role r,
|
|
||||||
zz_sys_role_menu rm,
|
|
||||||
zz_sys_menu m
|
|
||||||
<where>
|
|
||||||
AND ur.user_id = #{userId}
|
|
||||||
AND ur.role_id = r.role_id
|
|
||||||
AND ur.role_id = rm.role_id
|
|
||||||
AND rm.menu_id = m.menu_id
|
|
||||||
<if test="menuName != null and menuName != ''">
|
|
||||||
AND m.menu_name = #{menuName}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY
|
|
||||||
r.role_id, m.menu_id
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.webadmin.upms.dao.SysUserRoleMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysUserRole">
|
|
||||||
<id column="user_id" jdbcType="BIGINT" property="userId"/>
|
|
||||||
<id column="role_id" jdbcType="BIGINT" property="roleId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限与部门关联Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("数据权限与部门关联Dto")
|
|
||||||
@Data
|
|
||||||
public class SysDataPermDeptDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "数据权限Id", required = true)
|
|
||||||
private Long dataPermId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联部门Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "关联部门Id", required = true)
|
|
||||||
private Long deptId;
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.common.datafilter.constant.DataPermRuleType;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("数据权限Dto")
|
|
||||||
@Data
|
|
||||||
public class SysDataPermDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "数据权限Id", required = true)
|
|
||||||
@NotNull(message = "数据权限Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long dataPermId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "显示名称", required = true)
|
|
||||||
@NotBlank(message = "数据权限名称不能为空!")
|
|
||||||
private String dataPermName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "数据权限规则类型", required = true)
|
|
||||||
@NotNull(message = "数据权限规则类型不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = DataPermRuleType.class)
|
|
||||||
private Integer ruleType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门Id列表(逗号分隔)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(hidden = true)
|
|
||||||
private String deptIdListString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索字符串。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "LIKE 模糊搜索字符串")
|
|
||||||
private String searchString;
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SysDeptDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("SysDeptDto对象")
|
|
||||||
@Data
|
|
||||||
public class SysDeptDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "部门Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,部门Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "部门名称", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,部门名称不能为空!")
|
|
||||||
private String deptName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "显示顺序", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,显示顺序不能为空!")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父部门Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "父部门Id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建者Id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "更新者Id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "更新时间")
|
|
||||||
private Date updateTime;
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysMenuType;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("菜单Dto")
|
|
||||||
@Data
|
|
||||||
public class SysMenuDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "菜单Id", required = true)
|
|
||||||
@NotNull(message = "菜单Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long menuId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父菜单Id,目录菜单的父菜单为null
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "父菜单Id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单显示名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "菜单显示名称", required = true)
|
|
||||||
@NotBlank(message = "菜单显示名称不能为空!")
|
|
||||||
private String menuName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "菜单类型", required = true)
|
|
||||||
@NotNull(message = "菜单类型不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = SysMenuType.class, message = "数据验证失败,菜单类型为无效值!")
|
|
||||||
private Integer menuType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端表单路由名称,仅用于menu_type为1的菜单类型。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "前端表单路由名称")
|
|
||||||
private String formRouterName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线表单主键Id,仅用于在线表单绑定的菜单。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "在线表单主键Id")
|
|
||||||
private Long onlineFormId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单显示顺序 (值越小,排序越靠前)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "菜单显示顺序", required = true)
|
|
||||||
@NotNull(message = "菜单显示顺序不能为空!")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单图标。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "菜单显示顺序")
|
|
||||||
private String icon;
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作日志记录表
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("操作日志Dto")
|
|
||||||
@Data
|
|
||||||
public class SysOperationLogDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "主键Id")
|
|
||||||
private Long logId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作类型。
|
|
||||||
* 常量值定义可参考SysOperationLogType对象。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "操作类型")
|
|
||||||
private Integer operationType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每次请求的Id。
|
|
||||||
* 对于微服务之间的调用,在同一个请求的调用链中,该值是相同的。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "每次请求的Id")
|
|
||||||
private String traceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HTTP 请求地址。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "HTTP 请求地址")
|
|
||||||
private String requestUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应答状态。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "应答状态")
|
|
||||||
private Boolean success;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作员名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "操作员名称")
|
|
||||||
private String operatorName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用时长最小值。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "调用时长最小值")
|
|
||||||
private Long elapseMin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用时长最大值。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "调用时长最大值")
|
|
||||||
private Long elapseMax;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作开始时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "操作开始时间")
|
|
||||||
private String operationTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作开始时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "操作开始时间")
|
|
||||||
private String operationTimeEnd;
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysPermCodeType;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("权限字Dto")
|
|
||||||
@Data
|
|
||||||
public class SysPermCodeDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限字Id", required = true)
|
|
||||||
@NotNull(message = "权限字Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long permCodeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字标识(一般为有含义的英文字符串)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限字标识", required = true)
|
|
||||||
@NotBlank(message = "权限字编码不能为空!")
|
|
||||||
private String permCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级权限字Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "上级权限字Id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字类型(0: 表单 1: UI片段 2: 操作)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限字类型", required = true)
|
|
||||||
@NotNull(message = "权限字类型不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = SysPermCodeType.class, message = "数据验证失败,权限类型为无效值!")
|
|
||||||
private Integer permCodeType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "显示名称", required = true)
|
|
||||||
@NotBlank(message = "权限字显示名称不能为空!")
|
|
||||||
private String showName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序(数值越小,越靠前)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "显示顺序", required = true)
|
|
||||||
@NotNull(message = "权限字显示顺序不能为空!")
|
|
||||||
private Integer showOrder;
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("权限资源Dto")
|
|
||||||
@Data
|
|
||||||
public class SysPermDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限资源Id", required = true)
|
|
||||||
@NotNull(message = "权限Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long permId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限资源名称", required = true)
|
|
||||||
@NotBlank(message = "权限资源名称不能为空!")
|
|
||||||
private String permName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* shiro格式的权限字,如(upms:sysUser:add)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限字")
|
|
||||||
private String permCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限所在的权限模块Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限所在的权限模块Id")
|
|
||||||
@NotNull(message = "权限模块Id不能为空!")
|
|
||||||
private Long moduleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联的URL。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "关联的URL", required = true)
|
|
||||||
@NotBlank(message = "权限关联的url不能为空!")
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限在当前模块下的顺序,由小到大。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "显示顺序", required = true)
|
|
||||||
@NotNull(message = "权限显示顺序不能为空!")
|
|
||||||
private Integer showOrder;
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysPermModuleType;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源模块Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("权限资源模块Dto")
|
|
||||||
@Data
|
|
||||||
public class SysPermModuleDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限模块Id", required = true)
|
|
||||||
@NotNull(message = "权限模块Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long moduleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限模块名称", required = true)
|
|
||||||
@NotBlank(message = "权限模块名称不能为空!")
|
|
||||||
private String moduleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级权限模块Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "上级权限模块Id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块类型(0: 普通模块 1: Controller模块)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "权限模块类型", required = true)
|
|
||||||
@NotNull(message = "模块类型不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = SysPermModuleType.class, message = "数据验证失败,权限模块类型为无效值!")
|
|
||||||
private Integer moduleType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块在当前层级下的顺序,由小到大。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "显示顺序", required = true)
|
|
||||||
@NotNull(message = "权限模块显示顺序不能为空!")
|
|
||||||
private Integer showOrder;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("角色Dto")
|
|
||||||
@Data
|
|
||||||
public class SysRoleDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "角色Id", required = true)
|
|
||||||
@NotNull(message = "角色Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "角色名称", required = true)
|
|
||||||
@NotBlank(message = "角色名称不能为空!")
|
|
||||||
private String roleName;
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.AddGroup;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysUserType;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysUserStatus;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SysUserDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@ApiModel("SysUserDto对象")
|
|
||||||
@Data
|
|
||||||
public class SysUserDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,用户Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户名。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "登录用户名", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,登录用户名不能为空!")
|
|
||||||
private String loginName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户密码。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户密码", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,用户密码不能为空!", groups = {AddGroup.class})
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户显示名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户显示名称", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,用户显示名称不能为空!")
|
|
||||||
private String showName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户部门Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户部门Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,用户部门Id不能为空!")
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = SysUserType.class, message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)为无效值!")
|
|
||||||
private Integer userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户头像的Url。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户头像的Url")
|
|
||||||
private String headImageUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户状态(0: 正常 1: 锁定)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "用户状态(0: 正常 1: 锁定)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,用户状态(0: 正常 1: 锁定)不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = SysUserStatus.class, message = "数据验证失败,用户状态(0: 正常 1: 锁定)为无效值!")
|
|
||||||
private Integer userStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建者Id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "更新者Id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "更新时间")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createTime 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "createTime 范围过滤起始值(>=)")
|
|
||||||
private String createTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createTime 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "createTime 范围过滤结束值(<=)")
|
|
||||||
private String createTimeEnd;
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
|
||||||
import com.orangeforms.common.core.annotation.RelationManyToMany;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysDataPermVo;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_data_perm")
|
|
||||||
public class SysDataPerm {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "data_perm_id")
|
|
||||||
private Long dataPermId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "data_perm_name")
|
|
||||||
private String dataPermName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限规则类型(0: 全部可见 1: 只看自己 2: 只看本部门 3: 本部门及子部门 4: 多部门及子部门 5: 自定义部门列表)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "rule_type")
|
|
||||||
private Integer ruleType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String deptIdListString;
|
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
relationMapperName = "sysDataPermDeptMapper",
|
|
||||||
relationMasterIdField = "dataPermId",
|
|
||||||
relationModelClass = SysDataPermDept.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysDataPermDept> dataPermDeptList;
|
|
||||||
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String searchString;
|
|
||||||
|
|
||||||
public void setSearchString(String searchString) {
|
|
||||||
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysDataPermModelMapper extends BaseModelMapper<SysDataPermVo, SysDataPerm> {
|
|
||||||
/**
|
|
||||||
* 转换VO对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param sysDataPermVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "dataPermDeptList", expression = "java(mapToBean(sysDataPermVo.getDataPermDeptList(), com.orangeforms.webadmin.upms.model.SysDataPermDept.class))")
|
|
||||||
@Override
|
|
||||||
SysDataPerm toModel(SysDataPermVo sysDataPermVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param sysDataPerm 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "dataPermDeptList", expression = "java(beanToMap(sysDataPerm.getDataPermDeptList(), false))")
|
|
||||||
@Override
|
|
||||||
SysDataPermVo fromModel(SysDataPerm sysDataPerm);
|
|
||||||
}
|
|
||||||
public static final SysDataPermModelMapper INSTANCE = Mappers.getMapper(SysDataPerm.SysDataPermModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限与部门关联实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ToString(of = {"deptId"})
|
|
||||||
@TableName(value = "zz_sys_data_perm_dept")
|
|
||||||
public class SysDataPermDept {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "data_perm_id")
|
|
||||||
private Long dataPermId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联部门Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "dept_id")
|
|
||||||
private Long deptId;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限与用户关联实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_data_perm_user")
|
|
||||||
public class SysDataPermUser {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "data_perm_id")
|
|
||||||
private Long dataPermId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "user_id")
|
|
||||||
private Long userId;
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysDeptVo;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.*;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SysDept实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_dept")
|
|
||||||
public class SysDept {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "dept_id")
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "dept_name")
|
|
||||||
private String deptName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_order")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父部门Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "parent_id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
@TableField(value = "deleted_flag")
|
|
||||||
private Integer deletedFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysDeptModelMapper extends BaseModelMapper<SysDeptVo, SysDept> {
|
|
||||||
}
|
|
||||||
public static final SysDeptModelMapper INSTANCE = Mappers.getMapper(SysDeptModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门关联实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@TableName(value = "zz_sys_dept_relation")
|
|
||||||
public class SysDeptRelation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级部门Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "parent_dept_id")
|
|
||||||
private Long parentDeptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "dept_id")
|
|
||||||
private Long deptId;
|
|
||||||
}
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.common.core.annotation.RelationManyToMany;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysMenuVo;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_menu")
|
|
||||||
public class SysMenu {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "menu_id")
|
|
||||||
private Long menuId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父菜单Id,目录菜单的父菜单为null。
|
|
||||||
*/
|
|
||||||
@TableField(value = "parent_id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单显示名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "menu_name")
|
|
||||||
private String menuName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单类型(0: 目录 1: 菜单 2: 按钮 3: UI片段)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "menu_type")
|
|
||||||
private Integer menuType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端表单路由名称,仅用于menu_type为1的菜单类型。
|
|
||||||
*/
|
|
||||||
@TableField(value = "form_router_name")
|
|
||||||
private String formRouterName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线表单主键Id,仅用于在线表单绑定的菜单。
|
|
||||||
*/
|
|
||||||
@TableField(value = "online_form_id")
|
|
||||||
private Long onlineFormId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。
|
|
||||||
*/
|
|
||||||
@TableField(value = "online_menu_perm_type")
|
|
||||||
private Integer onlineMenuPermType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单显示顺序 (值越小,排序越靠前)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_order")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单图标。
|
|
||||||
*/
|
|
||||||
private String icon;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
relationMapperName = "sysMenuPermCodeMapper",
|
|
||||||
relationMasterIdField = "menuId",
|
|
||||||
relationModelClass = SysMenuPermCode.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysMenuPermCode> sysMenuPermCodeList;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysMenuModelMapper extends BaseModelMapper<SysMenuVo, SysMenu> {
|
|
||||||
/**
|
|
||||||
* 转换VO对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param sysMenuVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysMenuPermCodeList", expression = "java(mapToBean(sysMenuVo.getSysMenuPermCodeList(), com.orangeforms.webadmin.upms.model.SysMenuPermCode.class))")
|
|
||||||
@Override
|
|
||||||
SysMenu toModel(SysMenuVo sysMenuVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param sysMenu 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysMenuPermCodeList", expression = "java(beanToMap(sysMenu.getSysMenuPermCodeList(), false))")
|
|
||||||
@Override
|
|
||||||
SysMenuVo fromModel(SysMenu sysMenu);
|
|
||||||
}
|
|
||||||
public static final SysMenuModelMapper INSTANCE = Mappers.getMapper(SysMenu.SysMenuModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单与权限字关联实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_menu_perm_code")
|
|
||||||
public class SysMenuPermCode {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联菜单Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "menu_id")
|
|
||||||
private Long menuId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联权限字Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_code_id")
|
|
||||||
private Long permCodeId;
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.common.core.annotation.RelationDict;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_perm")
|
|
||||||
public class SysPerm {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "perm_id")
|
|
||||||
private Long permId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限所在的权限模块Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "module_id")
|
|
||||||
private Long moduleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_name")
|
|
||||||
private String permName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联的URL。
|
|
||||||
*/
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限在当前模块下的顺序,由小到大。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_order")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "moduleId",
|
|
||||||
slaveServiceName = "SysPermModuleService",
|
|
||||||
slaveModelClass = SysPermModule.class,
|
|
||||||
slaveIdField = "moduleId",
|
|
||||||
slaveNameField = "moduleName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> moduleIdDictMap;
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.common.core.annotation.RelationManyToMany;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysPermCodeVo;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_perm_code")
|
|
||||||
public class SysPermCode {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "perm_code_id")
|
|
||||||
private Long permCodeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级权限字Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "parent_id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字标识(一般为有含义的英文字符串)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_code")
|
|
||||||
private String permCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限类型(0: 表单 1: UI片段 2: 操作)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_code_type")
|
|
||||||
private Integer permCodeType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_name")
|
|
||||||
private String showName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序(数值越小,越靠前)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_order")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
relationMapperName = "sysPermCodePermMapper",
|
|
||||||
relationMasterIdField = "permCodeId",
|
|
||||||
relationModelClass = SysPermCodePerm.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysPermCodePerm> sysPermCodePermList;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysPermCodeModelMapper extends BaseModelMapper<SysPermCodeVo, SysPermCode> {
|
|
||||||
/**
|
|
||||||
* 转换VO对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param sysPermCodeVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysPermCodePermList", expression = "java(mapToBean(sysPermCodeVo.getSysPermCodePermList(), com.orangeforms.webadmin.upms.model.SysPermCodePerm.class))")
|
|
||||||
@Override
|
|
||||||
SysPermCode toModel(SysPermCodeVo sysPermCodeVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysPermCodePermList", expression = "java(beanToMap(sysPermCode.getSysPermCodePermList(), false))")
|
|
||||||
@Override
|
|
||||||
SysPermCodeVo fromModel(SysPermCode sysPermCode);
|
|
||||||
}
|
|
||||||
public static final SysPermCodeModelMapper INSTANCE = Mappers.getMapper(SysPermCode.SysPermCodeModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字与权限资源关联实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_perm_code_perm")
|
|
||||||
public class SysPermCodePerm {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_code_id")
|
|
||||||
private Long permCodeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_id")
|
|
||||||
private Long permId;
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_perm_module")
|
|
||||||
public class SysPermModule {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "module_id")
|
|
||||||
private Long moduleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上级权限模块Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "parent_id")
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "module_name")
|
|
||||||
private String moduleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块类型(0: 普通模块 1: Controller模块)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "module_type")
|
|
||||||
private Integer moduleType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限模块在当前层级下的顺序,由小到大。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_order")
|
|
||||||
private Integer showOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysPerm> sysPermList;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 白名单实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_perm_whitelist")
|
|
||||||
public class SysPermWhitelist {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源的URL。
|
|
||||||
*/
|
|
||||||
@TableId(value = "perm_url")
|
|
||||||
private String permUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源所属模块名字(通常是Controller的名字)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "module_name")
|
|
||||||
private String moduleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限的名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "perm_name")
|
|
||||||
private String permName;
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.common.core.annotation.RelationManyToMany;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysRoleVo;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_role")
|
|
||||||
public class SysRole {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "role_id")
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "role_name")
|
|
||||||
private String roleName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
relationMapperName = "sysRoleMenuMapper",
|
|
||||||
relationMasterIdField = "roleId",
|
|
||||||
relationModelClass = SysRoleMenu.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysRoleMenu> sysRoleMenuList;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysRoleModelMapper extends BaseModelMapper<SysRoleVo, SysRole> {
|
|
||||||
/**
|
|
||||||
* 转换VO对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param sysRoleVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysRoleMenuList", expression = "java(mapToBean(sysRoleVo.getSysRoleMenuList(), com.orangeforms.webadmin.upms.model.SysRoleMenu.class))")
|
|
||||||
@Override
|
|
||||||
SysRole toModel(SysRoleVo sysRoleVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param sysRole 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysRoleMenuList", expression = "java(beanToMap(sysRole.getSysRoleMenuList(), false))")
|
|
||||||
@Override
|
|
||||||
SysRoleVo fromModel(SysRole sysRole);
|
|
||||||
}
|
|
||||||
public static final SysRoleModelMapper INSTANCE = Mappers.getMapper(SysRole.SysRoleModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色菜单实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_role_menu")
|
|
||||||
public class SysRoleMenu {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "role_id")
|
|
||||||
private Long roleId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "menu_id")
|
|
||||||
private Long menuId;
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysUserType;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysUserStatus;
|
|
||||||
import com.orangeforms.common.core.upload.UploadStoreTypeEnum;
|
|
||||||
import com.orangeforms.common.core.annotation.*;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.vo.SysUserVo;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.*;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SysUser实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_user")
|
|
||||||
public class SysUser {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "user_id")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录用户名。
|
|
||||||
*/
|
|
||||||
@TableField(value = "login_name")
|
|
||||||
private String loginName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户密码。
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户显示名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "show_name")
|
|
||||||
private String showName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户部门Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "dept_id")
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "user_type")
|
|
||||||
private Integer userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户头像的Url。
|
|
||||||
*/
|
|
||||||
@UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
|
|
||||||
@TableField(value = "head_image_url")
|
|
||||||
private String headImageUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户状态(0: 正常 1: 锁定)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "user_status")
|
|
||||||
private Integer userStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
@TableField(value = "deleted_flag")
|
|
||||||
private Integer deletedFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_user_id")
|
|
||||||
private Long updateUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createTime 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String createTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createTime 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String createTimeEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多对多用户角色数据集合。
|
|
||||||
*/
|
|
||||||
@RelationManyToMany(
|
|
||||||
relationMapperName = "sysUserRoleMapper",
|
|
||||||
relationMasterIdField = "userId",
|
|
||||||
relationModelClass = SysUserRole.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysUserRole> sysUserRoleList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多对多用户数据权限数据集合。
|
|
||||||
*/
|
|
||||||
@RelationManyToMany(
|
|
||||||
relationMapperName = "sysDataPermUserMapper",
|
|
||||||
relationMasterIdField = "userId",
|
|
||||||
relationModelClass = SysDataPermUser.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private List<SysDataPermUser> sysDataPermUserList;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "deptId",
|
|
||||||
slaveServiceName = "sysDeptService",
|
|
||||||
slaveModelClass = SysDept.class,
|
|
||||||
slaveIdField = "deptId",
|
|
||||||
slaveNameField = "deptName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> deptIdDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "userType",
|
|
||||||
constantDictClass = SysUserType.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> userTypeDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "userStatus",
|
|
||||||
constantDictClass = SysUserStatus.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> userStatusDictMap;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysUserModelMapper extends BaseModelMapper<SysUserVo, SysUser> {
|
|
||||||
/**
|
|
||||||
* 转换Vo对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param sysUserVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysUserRoleList", expression = "java(mapToBean(sysUserVo.getSysUserRoleList(), com.orangeforms.webadmin.upms.model.SysUserRole.class))")
|
|
||||||
@Mapping(target = "sysDataPermUserList", expression = "java(mapToBean(sysUserVo.getSysDataPermUserList(), com.orangeforms.webadmin.upms.model.SysDataPermUser.class))")
|
|
||||||
@Override
|
|
||||||
SysUser toModel(SysUserVo sysUserVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param sysUser 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "sysUserRoleList", expression = "java(beanToMap(sysUser.getSysUserRoleList(), false))")
|
|
||||||
@Mapping(target = "sysDataPermUserList", expression = "java(beanToMap(sysUser.getSysDataPermUserList(), false))")
|
|
||||||
@Override
|
|
||||||
SysUserVo fromModel(SysUser sysUser);
|
|
||||||
}
|
|
||||||
public static final SysUserModelMapper INSTANCE = Mappers.getMapper(SysUserModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户角色实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_sys_user_role")
|
|
||||||
public class SysUserRole {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "user_id")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "role_id")
|
|
||||||
private Long roleId;
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单类型常量对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public final class SysMenuType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 目录菜单。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_DIRECTORY = 0;
|
|
||||||
/**
|
|
||||||
* 普通菜单。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_MENU = 1;
|
|
||||||
/**
|
|
||||||
* 表单片段类型。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_UI_FRAGMENT = 2;
|
|
||||||
/**
|
|
||||||
* 按钮类型。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_BUTTON = 3;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(4);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(TYPE_DIRECTORY, "目录菜单");
|
|
||||||
DICT_MAP.put(TYPE_MENU, "普通菜单");
|
|
||||||
DICT_MAP.put(TYPE_UI_FRAGMENT, "表单片段类型");
|
|
||||||
DICT_MAP.put(TYPE_BUTTON, "按钮类型");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private SysMenuType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单关联在线表单的控制权限类型。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public final class SysOnlineMenuPermType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_VIEW = 0;
|
|
||||||
/**
|
|
||||||
* 编辑。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_EDIT = 1;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(4);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(TYPE_VIEW, "查看");
|
|
||||||
DICT_MAP.put(TYPE_EDIT, "编辑");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private SysOnlineMenuPermType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字类型常量对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public final class SysPermCodeType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单权限字。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_FORM = 0;
|
|
||||||
/**
|
|
||||||
* 表单片段布局权限字。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_FRAGMENT = 1;
|
|
||||||
/**
|
|
||||||
* 操作权限字。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_OPERATION = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(TYPE_FORM, "表单权限字");
|
|
||||||
DICT_MAP.put(TYPE_FRAGMENT, "表单片段布局权限字");
|
|
||||||
DICT_MAP.put(TYPE_OPERATION, "操作权限字");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private SysPermCodeType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源模块类型常量对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public final class SysPermModuleType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 普通模块。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_NORMAL = 0;
|
|
||||||
/**
|
|
||||||
* controller接口模块。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_CONTROLLER = 1;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(TYPE_NORMAL, "普通模块");
|
|
||||||
DICT_MAP.put(TYPE_CONTROLLER, "controller接口模块");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private SysPermModuleType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户状态常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public final class SysUserStatus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正常状态。
|
|
||||||
*/
|
|
||||||
public static final int STATUS_NORMAL = 0;
|
|
||||||
/**
|
|
||||||
* 锁定状态。
|
|
||||||
*/
|
|
||||||
public static final int STATUS_LOCKED = 1;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(STATUS_NORMAL, "正常状态");
|
|
||||||
DICT_MAP.put(STATUS_LOCKED, "锁定状态");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private SysUserStatus() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.model.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public final class SysUserType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理员。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_ADMIN = 0;
|
|
||||||
/**
|
|
||||||
* 系统操作员。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_SYSTEM = 1;
|
|
||||||
/**
|
|
||||||
* 普通操作员。
|
|
||||||
*/
|
|
||||||
public static final int TYPE_OPERATOR = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(TYPE_ADMIN, "管理员");
|
|
||||||
DICT_MAP.put(TYPE_SYSTEM, "系统操作员");
|
|
||||||
DICT_MAP.put(TYPE_OPERATOR, "普通操作员");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private SysUserType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限数据服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDataPermService extends IBaseService<SysDataPerm, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的数据权限对象。
|
|
||||||
*
|
|
||||||
* @param dataPerm 新增的数据权限对象。
|
|
||||||
* @param deptIdSet 关联的部门Id列表。
|
|
||||||
* @return 新增后的数据权限对象。
|
|
||||||
*/
|
|
||||||
SysDataPerm saveNew(SysDataPerm dataPerm, Set<Long> deptIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据权限对象。
|
|
||||||
*
|
|
||||||
* @param dataPerm 更新的数据权限对象。
|
|
||||||
* @param originalDataPerm 原有的数据权限对象。
|
|
||||||
* @param deptIdSet 关联的部门Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysDataPerm dataPerm, SysDataPerm originalDataPerm, Set<Long> deptIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据权限。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long dataPermId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据权限列表。
|
|
||||||
*
|
|
||||||
* @param filter 数据权限过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 数据权限查询列表。
|
|
||||||
*/
|
|
||||||
List<SysDataPerm> getSysDataPermList(SysDataPerm filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定用户的指定会话的数据权限集合存入缓存。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @param deptId 用户所属部门主键Id。
|
|
||||||
* @return 查询并缓存后的数据权限集合。返回格式为,Map<RuleType, DeptIdString>。
|
|
||||||
*/
|
|
||||||
Map<Integer, String> putDataPermCache(String sessionId, Long userId, Long deptId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定会话的数据权限集合从缓存中移除。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
*/
|
|
||||||
void removeDataPermCache(String sessionId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户Id的数据权限列表。并基于权限规则类型进行了一级分组。
|
|
||||||
*
|
|
||||||
* @param userId 指定的用户Id。
|
|
||||||
* @param deptId 用户所属部门主键Id。
|
|
||||||
* @return 合并优化后的数据权限列表。返回格式为,Map<RuleType, DeptIdString>。
|
|
||||||
*/
|
|
||||||
Map<Integer, String> getSysDataPermListByUserId(Long userId, Long deptId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加用户和数据权限之间的多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限Id。
|
|
||||||
* @param userIdSet 关联的用户Id列表。
|
|
||||||
*/
|
|
||||||
void addDataPermUserList(Long dataPermId, Set<Long> userIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除用户和数据权限之间的多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return true移除成功,否则false。
|
|
||||||
*/
|
|
||||||
boolean removeDataPermUser(Long dataPermId, Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证数据权限对象关联菜单数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param dataPerm 数据权限关对象。
|
|
||||||
* @param deptIdListString 与数据权限关联的部门Id列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
CallResult verifyRelatedData(SysDataPerm dataPerm, String deptIdListString);
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门管理数据操作服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysDeptService extends IBaseService<SysDept, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的部门对象。
|
|
||||||
*
|
|
||||||
* @param sysDept 新增的部门对象。
|
|
||||||
* @param parentSysDept 上级部门对象。
|
|
||||||
* @return 新增后的部门对象。
|
|
||||||
*/
|
|
||||||
SysDept saveNew(SysDept sysDept, SysDept parentSysDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新部门对象。
|
|
||||||
*
|
|
||||||
* @param sysDept 更新的部门对象。
|
|
||||||
* @param originalSysDept 原有的部门对象。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysDept sysDept, SysDept originalSysDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param deptId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long deptId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getSysDeptListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<SysDept> getSysDeptList(SysDept filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getSysDeptList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<SysDept> getSysDeptListWithRelation(SysDept filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断指定对象是否包含下级对象。
|
|
||||||
*
|
|
||||||
* @param deptId 主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean hasChildren(Long deptId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断指定部门Id是否包含用户对象。
|
|
||||||
*
|
|
||||||
* @param deptId 部门主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean hasChildrenUser(Long deptId);
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenu;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单数据服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysMenuService extends IBaseService<SysMenu, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的菜单对象。
|
|
||||||
*
|
|
||||||
* @param sysMenu 新增的菜单对象。
|
|
||||||
* @param permCodeIdSet 权限字Id列表。
|
|
||||||
* @return 新增后的菜单对象。
|
|
||||||
*/
|
|
||||||
SysMenu saveNew(SysMenu sysMenu, Set<Long> permCodeIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新菜单对象。
|
|
||||||
*
|
|
||||||
* @param sysMenu 更新的菜单对象。
|
|
||||||
* @param originalSysMenu 原有的菜单对象。
|
|
||||||
* @param permCodeIdSet 权限字Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysMenu sysMenu, SysMenu originalSysMenu, Set<Long> permCodeIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定的菜单。
|
|
||||||
*
|
|
||||||
* @param menu 菜单对象。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(SysMenu menu);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取全部菜单列表。
|
|
||||||
*
|
|
||||||
* @return 全部菜单列表。
|
|
||||||
*/
|
|
||||||
Collection<SysMenu> getAllMenuList();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户Id的菜单列表,已去重。
|
|
||||||
*
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 用户关联的菜单列表。
|
|
||||||
*/
|
|
||||||
Collection<SysMenu> getMenuListByUserId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前菜单是否存在子菜单。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean hasChildren(Long menuId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证菜单对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysMenu 当前操作的对象。
|
|
||||||
* @param originalSysMenu 原有对象。
|
|
||||||
* @param permCodeIdListString 逗号分隔的权限Id列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu, String permCodeIdListString);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param url 权限资源地址过滤条件。
|
|
||||||
* @return 包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermListWithDetail(Long menuId, String url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysUserListWithDetail(Long menuId, String loginName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定类型的所有在线表单的菜单。
|
|
||||||
*
|
|
||||||
* @param menuType 菜单类型,NULL则返回全部类型。
|
|
||||||
* @return 在线表单关联的菜单列表。
|
|
||||||
*/
|
|
||||||
List<SysMenu> getAllOnlineMenuList(Integer menuType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前用户有权访问的在线表单菜单,仅返回类型为BUTTON的菜单。
|
|
||||||
*
|
|
||||||
* @param userId 指定的用户。
|
|
||||||
* @param menuType 菜单类型,NULL则返回全部类型。
|
|
||||||
* @return 在线表单关联的菜单列表。
|
|
||||||
*/
|
|
||||||
List<SysMenu> getOnlineMenuListByUserId(Long userId, Integer menuType);
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCode;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字数据服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermCodeService extends IBaseService<SysPermCode, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户的权限字列表,已去重。
|
|
||||||
*
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 用户关联的权限字列表。
|
|
||||||
*/
|
|
||||||
Collection<String> getPermCodeListByUserId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有权限字数据列表,已去重。
|
|
||||||
*
|
|
||||||
* @return 全部权限字列表。
|
|
||||||
*/
|
|
||||||
Collection<String> getAllPermCodeList();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的权限字对象。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 新增的权限字对象。
|
|
||||||
* @param permIdSet 权限资源Id列表。
|
|
||||||
* @return 新增后的权限字对象。
|
|
||||||
*/
|
|
||||||
SysPermCode saveNew(SysPermCode sysPermCode, Set<Long> permIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限字对象。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 更新的权限字对象。
|
|
||||||
* @param originalSysPermCode 原有的权限字对象。
|
|
||||||
* @param permIdSet 权限资源Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysPermCode sysPermCode, SysPermCode originalSysPermCode, Set<Long> permIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定的权限字。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long permCodeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前权限字是否存在下级权限字对象。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean hasChildren(Long permCodeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证权限字对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 当前操作的对象。
|
|
||||||
* @param originalSysPermCode 原有对象。
|
|
||||||
* @param permIdListString 逗号分隔的权限资源Id列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
CallResult verifyRelatedData(SysPermCode sysPermCode, SysPermCode originalSysPermCode, String permIdListString);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysUserListWithDetail(Long permCodeId, String loginName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 包含从权限字到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysRoleListWithDetail(Long permCodeId, String roleName);
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermModule;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源模块数据服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermModuleService extends IBaseService<SysPermModule, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的权限资源模块对象。
|
|
||||||
*
|
|
||||||
* @param sysPermModule 新增的权限资源模块对象。
|
|
||||||
* @return 新增后的权限资源模块对象。
|
|
||||||
*/
|
|
||||||
SysPermModule saveNew(SysPermModule sysPermModule);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限资源模块对象。
|
|
||||||
*
|
|
||||||
* @param sysPermModule 更新的权限资源模块对象。
|
|
||||||
* @param originalSysPermModule 原有的权限资源模块对象。
|
|
||||||
* @return 更新成功返回true,否则false
|
|
||||||
*/
|
|
||||||
boolean update(SysPermModule sysPermModule, SysPermModule originalSysPermModule);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定的权限资源模块。
|
|
||||||
*
|
|
||||||
* @param moduleId 权限资源模块主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long moduleId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取权限模块资源及其关联的权限资源列表。
|
|
||||||
*
|
|
||||||
* @return 权限资源模块及其关联的权限资源列表。
|
|
||||||
*/
|
|
||||||
List<SysPermModule> getPermModuleAndPermList();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否存在下级权限资源模块。
|
|
||||||
*
|
|
||||||
* @param moduleId 权限资源模块主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean hasChildren(Long moduleId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否存在权限数据。
|
|
||||||
*
|
|
||||||
* @param moduleId 权限资源模块主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean hasModulePerms(Long moduleId);
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPerm;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源数据服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermService extends IBaseService<SysPerm, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的权限资源对象。
|
|
||||||
*
|
|
||||||
* @param perm 新增的权限资源对象。
|
|
||||||
* @return 新增后的权限资源对象。
|
|
||||||
*/
|
|
||||||
SysPerm saveNew(SysPerm perm);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限资源对象。
|
|
||||||
*
|
|
||||||
* @param perm 更新的权限资源对象。
|
|
||||||
* @param originalPerm 原有的权限资源对象。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysPerm perm, SysPerm originalPerm);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除权限资源。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long permId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取权限数据列表。
|
|
||||||
*
|
|
||||||
* @param sysPermFilter 过滤对象。
|
|
||||||
* @return 权限列表。
|
|
||||||
*/
|
|
||||||
List<SysPerm> getPermListWithRelation(SysPerm sysPermFilter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定用户的指定会话的权限集合存入缓存。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 查询并缓存后的权限集合。
|
|
||||||
*/
|
|
||||||
Collection<String> putUserSysPermCache(String sessionId, Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 把在线表单的权限URL集合,存放到权限URL的缓存中。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
* @param permUrlSet URL集合。
|
|
||||||
*/
|
|
||||||
void putOnlinePermToCache(String sessionId, Set<String> permUrlSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定会话的权限集合从缓存中移除。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
*/
|
|
||||||
void removeUserSysPermCache(String sessionId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取与指定用户关联的权限资源列表,已去重。
|
|
||||||
*
|
|
||||||
* @param userId 关联的用户主键Id。
|
|
||||||
* @return 与指定用户Id关联的权限资源列表。
|
|
||||||
*/
|
|
||||||
Collection<String> getPermListByUserId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysUserListWithDetail(Long permId, String loginName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysRoleListWithDetail(Long permId, String roleName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param menuName 菜单名。
|
|
||||||
* @return 包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysMenuListWithDetail(Long permId, String menuName);
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermWhitelist;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源白名单数据服务接口。
|
|
||||||
* 白名单中的权限资源,可以不受权限控制,任何用户皆可访问,一般用于常用的字典数据列表接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysPermWhitelistService extends IBaseService<SysPermWhitelist, String> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取白名单权限资源的列表。
|
|
||||||
*
|
|
||||||
* @return 白名单权限资源地址列表。
|
|
||||||
*/
|
|
||||||
List<String> getWhitelistPermList();
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysRole;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysUserRole;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色数据服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysRoleService extends IBaseService<SysRole, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的角色对象。
|
|
||||||
*
|
|
||||||
* @param role 新增的角色对象。
|
|
||||||
* @param menuIdSet 菜单Id列表。
|
|
||||||
* @return 新增后的角色对象。
|
|
||||||
*/
|
|
||||||
SysRole saveNew(SysRole role, Set<Long> menuIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新角色对象。
|
|
||||||
*
|
|
||||||
* @param role 更新的角色对象。
|
|
||||||
* @param originalRole 原有的角色对象。
|
|
||||||
* @param menuIdSet 菜单Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysRole role, SysRole originalRole, Set<Long> menuIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定角色。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long roleId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色列表。
|
|
||||||
*
|
|
||||||
* @param filter 角色过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 角色列表。
|
|
||||||
*/
|
|
||||||
List<SysRole> getSysRoleList(SysRole filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户的用户角色对象列表。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @return 用户角色对象列表。
|
|
||||||
*/
|
|
||||||
List<SysUserRole> getSysUserRoleListByUserId(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增用户角色关联。
|
|
||||||
*
|
|
||||||
* @param userRoleList 用户角色关系数据列表。
|
|
||||||
*/
|
|
||||||
void addUserRoleList(List<SysUserRole> userRoleList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除指定用户和指定角色的关联关系。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 移除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean removeUserRole(Long roleId, Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证角色对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysRole 当前操作的对象。
|
|
||||||
* @param originalSysRole 原有对象。
|
|
||||||
* @param menuIdListString 逗号分隔的menuId列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询角色的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param roleId 角色Id。
|
|
||||||
* @param url url过滤条件。
|
|
||||||
* @return 包含从角色到权限资源的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermListWithDetail(Long roleId, String url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询角色的权限字列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param roleId 角色Id。
|
|
||||||
* @param permCode 权限字名称过滤条件。
|
|
||||||
* @return 包含从角色到权限字的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermCodeListWithDetail(Long roleId, String permCode);
|
|
||||||
}
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service;
|
|
||||||
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户管理数据操作服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
public interface SysUserService extends IBaseService<SysUser, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定登录名的用户对象。
|
|
||||||
*
|
|
||||||
* @param loginName 指定登录用户名。
|
|
||||||
* @return 用户对象。
|
|
||||||
*/
|
|
||||||
SysUser getSysUserByLoginName(String loginName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的用户对象。
|
|
||||||
*
|
|
||||||
* @param user 新增的用户对象。
|
|
||||||
* @param roleIdSet 用户角色Id集合。
|
|
||||||
* @param dataPermIdSet 数据权限Id集合。
|
|
||||||
* @return 新增后的用户对象。
|
|
||||||
*/
|
|
||||||
SysUser saveNew(SysUser user, Set<Long> roleIdSet, Set<Long> dataPermIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新用户对象。
|
|
||||||
*
|
|
||||||
* @param user 更新的用户对象。
|
|
||||||
* @param originalUser 原有的用户对象。
|
|
||||||
* @param roleIdSet 用户角色Id列表。
|
|
||||||
* @param dataPermIdSet 数据权限Id集合。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(SysUser user, SysUser originalUser, Set<Long> roleIdSet, Set<Long> dataPermIdSet);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改用户密码。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @param newPass 新密码。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean changePassword(Long userId, String newPass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改用户头像。
|
|
||||||
*
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @param newHeadImage 新的头像信息。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean changeHeadImage(Long userId, String newHeadImage);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param userId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getSysUserListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserList(SysUser filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getSysUserList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserListWithRelation(SysUser filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定角色的用户列表。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @param filter 用户过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取不属于指定角色的用户列表。
|
|
||||||
*
|
|
||||||
* @param roleId 角色主键Id。
|
|
||||||
* @param filter 用户过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定数据权限的用户列表。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @param filter 用户过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取不属于指定数据权限的用户列表。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @param filter 用户过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 用户列表。
|
|
||||||
*/
|
|
||||||
List<SysUser> getNotInSysUserListByDataPermId(Long dataPermId, SysUser filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param url url过滤条件。
|
|
||||||
* @return 包含从用户到权限资源的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermListWithDetail(Long userId, String url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的权限字列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param permCode 权限字名称过滤条件。
|
|
||||||
* @return 包含从用户到权限字的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysPermCodeListWithDetail(Long userId, String permCode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param userId 用户Id。
|
|
||||||
* @param menuName 菜单名称过滤条件。
|
|
||||||
* @return 包含从用户到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getSysMenuListWithDetail(Long userId, String menuName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证用户对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysUser 当前操作的对象。
|
|
||||||
* @param originalSysUser 原有对象。
|
|
||||||
* @param roleIds 逗号分隔的角色Id列表字符串。
|
|
||||||
* @param dataPermIds 逗号分隔的数据权限Id列表字符串。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
CallResult verifyRelatedData(
|
|
||||||
SysUser sysUser, SysUser originalSysUser, String roleIds, String dataPermIds);
|
|
||||||
}
|
|
||||||
@@ -1,334 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import com.orangeforms.common.datafilter.constant.DataPermRuleType;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.util.RedisKeyUtil;
|
|
||||||
import com.orangeforms.webadmin.config.ApplicationConfig;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysDataPermDeptMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysDataPermMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysDataPermUserMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysDataPermService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysDeptService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.redisson.api.RBucket;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限数据服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sysDataPermService")
|
|
||||||
public class SysDataPermServiceImpl extends BaseService<SysDataPerm, Long> implements SysDataPermService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysDataPermMapper sysDataPermMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysDataPermDeptMapper sysDataPermDeptMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysDataPermUserMapper sysDataPermUserMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysDeptService sysDeptService;
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig applicationConfig;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回主对象的Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主对象的Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<SysDataPerm> mapper() {
|
|
||||||
return sysDataPermMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的数据权限对象。
|
|
||||||
*
|
|
||||||
* @param dataPerm 新增的数据权限对象。
|
|
||||||
* @param deptIdSet 关联的部门Id列表。
|
|
||||||
* @return 新增后的数据权限对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public SysDataPerm saveNew(SysDataPerm dataPerm, Set<Long> deptIdSet) {
|
|
||||||
dataPerm.setDataPermId(idGenerator.nextLongId());
|
|
||||||
MyModelUtil.fillCommonsForInsert(dataPerm);
|
|
||||||
sysDataPermMapper.insert(dataPerm);
|
|
||||||
this.insertRelationData(dataPerm, deptIdSet);
|
|
||||||
return dataPerm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据权限对象。
|
|
||||||
*
|
|
||||||
* @param dataPerm 更新的数据权限对象。
|
|
||||||
* @param originalDataPerm 原有的数据权限对象。
|
|
||||||
* @param deptIdSet 关联的部门Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(SysDataPerm dataPerm, SysDataPerm originalDataPerm, Set<Long> deptIdSet) {
|
|
||||||
MyModelUtil.fillCommonsForUpdate(dataPerm, originalDataPerm);
|
|
||||||
UpdateWrapper<SysDataPerm> uw = this.createUpdateQueryForNullValue(dataPerm, dataPerm.getDataPermId());
|
|
||||||
if (sysDataPermMapper.update(dataPerm, uw) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysDataPermDept dataPermDept = new SysDataPermDept();
|
|
||||||
dataPermDept.setDataPermId(dataPerm.getDataPermId());
|
|
||||||
sysDataPermDeptMapper.delete(new QueryWrapper<>(dataPermDept));
|
|
||||||
this.insertRelationData(dataPerm, deptIdSet);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据权限。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long dataPermId) {
|
|
||||||
if (sysDataPermMapper.deleteById(dataPermId) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysDataPermDept dataPermDept = new SysDataPermDept();
|
|
||||||
dataPermDept.setDataPermId(dataPermId);
|
|
||||||
sysDataPermDeptMapper.delete(new QueryWrapper<>(dataPermDept));
|
|
||||||
SysDataPermUser dataPermUser = new SysDataPermUser();
|
|
||||||
dataPermUser.setDataPermId(dataPermId);
|
|
||||||
sysDataPermUserMapper.delete(new QueryWrapper<>(dataPermUser));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取数据权限列表。
|
|
||||||
*
|
|
||||||
* @param filter 数据权限过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 数据权限查询列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysDataPerm> getSysDataPermList(SysDataPerm filter, String orderBy) {
|
|
||||||
return sysDataPermMapper.getSysDataPermList(filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定用户的指定会话的数据权限集合存入缓存。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @param deptId 用户所属部门主键Id。
|
|
||||||
* @return 查询并缓存后的数据权限集合。返回格式为,Map<RuleType, DeptIdString>。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Map<Integer, String> putDataPermCache(String sessionId, Long userId, Long deptId) {
|
|
||||||
Map<Integer, String> dataPermMap = this.getSysDataPermListByUserId(userId, deptId);
|
|
||||||
if (dataPermMap.size() > 0) {
|
|
||||||
String dataPermSessionKey = RedisKeyUtil.makeSessionDataPermIdKey(sessionId);
|
|
||||||
RBucket<String> bucket = redissonClient.getBucket(dataPermSessionKey);
|
|
||||||
bucket.set(JSON.toJSONString(dataPermMap),
|
|
||||||
applicationConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
return dataPermMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定会话的数据权限集合从缓存中移除。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeDataPermCache(String sessionId) {
|
|
||||||
String sessionPermKey = RedisKeyUtil.makeSessionDataPermIdKey(sessionId);
|
|
||||||
redissonClient.getBucket(sessionPermKey).deleteAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户Id的数据权限列表。并基于权限规则类型进行了一级分组。
|
|
||||||
*
|
|
||||||
* @param userId 指定的用户Id。
|
|
||||||
* @param deptId 用户所属部门主键Id。
|
|
||||||
* @return 合并优化后的数据权限列表。返回格式为,Map<RuleType, DeptIdString>。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Map<Integer, String> getSysDataPermListByUserId(Long userId, Long deptId) {
|
|
||||||
List<SysDataPerm> dataPermList = sysDataPermMapper.getSysDataPermListByUserId(userId);
|
|
||||||
dataPermList.forEach(dataPerm -> {
|
|
||||||
if (CollectionUtils.isNotEmpty(dataPerm.getDataPermDeptList())) {
|
|
||||||
Set<Long> deptIdSet = dataPerm.getDataPermDeptList().stream()
|
|
||||||
.map(SysDataPermDept::getDeptId).collect(Collectors.toSet());
|
|
||||||
dataPerm.setDeptIdListString(StringUtils.join(deptIdSet, ","));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 为了更方便进行后续的合并优化处理,这里再基于规则类型进行分组。ruleMap的key是规则类型。
|
|
||||||
Map<Integer, List<SysDataPerm>> ruleMap =
|
|
||||||
dataPermList.stream().collect(Collectors.groupingBy(SysDataPerm::getRuleType));
|
|
||||||
Map<Integer, String> resultMap = new HashMap<>(ruleMap.size());
|
|
||||||
// 如有有ALL存在,就可以直接退出了,没有必要在处理后续的规则了。
|
|
||||||
if (ruleMap.containsKey(DataPermRuleType.TYPE_ALL)) {
|
|
||||||
resultMap.put(DataPermRuleType.TYPE_ALL, "null");
|
|
||||||
return resultMap;
|
|
||||||
}
|
|
||||||
// 这里优先合并最复杂的多部门及子部门场景。
|
|
||||||
String deptIds = processMultiDeptAndChildren(ruleMap, deptId);
|
|
||||||
if (deptIds != null) {
|
|
||||||
resultMap.put(DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT, deptIds);
|
|
||||||
}
|
|
||||||
// 合并当前部门及子部门的优化
|
|
||||||
if (ruleMap.get(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT) != null) {
|
|
||||||
// 需要与仅仅当前部门规则进行合并。
|
|
||||||
ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY);
|
|
||||||
resultMap.put(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT, "null");
|
|
||||||
}
|
|
||||||
// 合并自定义部门了。
|
|
||||||
deptIds = processMultiDept(ruleMap, deptId);
|
|
||||||
if (deptIds != null) {
|
|
||||||
resultMap.put(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST, deptIds);
|
|
||||||
}
|
|
||||||
// 最后处理当前部门和当前用户。
|
|
||||||
if (ruleMap.get(DataPermRuleType.TYPE_DEPT_ONLY) != null) {
|
|
||||||
resultMap.put(DataPermRuleType.TYPE_DEPT_ONLY, "null");
|
|
||||||
}
|
|
||||||
if (ruleMap.get(DataPermRuleType.TYPE_USER_ONLY) != null) {
|
|
||||||
resultMap.put(DataPermRuleType.TYPE_USER_ONLY, "null");
|
|
||||||
}
|
|
||||||
return resultMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String processMultiDeptAndChildren(Map<Integer, List<SysDataPerm>> ruleMap, Long deptId) {
|
|
||||||
List<SysDataPerm> parentDeptList = ruleMap.get(DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT);
|
|
||||||
if (parentDeptList == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Set<Long> deptIdSet = new HashSet<>();
|
|
||||||
for (SysDataPerm parentDept : parentDeptList) {
|
|
||||||
deptIdSet.addAll(Arrays.stream(StringUtils.split(
|
|
||||||
parentDept.getDeptIdListString(), ",")).map(Long::valueOf).collect(Collectors.toSet()));
|
|
||||||
}
|
|
||||||
// 在合并所有的多父部门Id之后,需要判断是否有本部门及子部门的规则。如果有,就继续合并。
|
|
||||||
if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT)) {
|
|
||||||
// 如果多父部门列表中包含当前部门,那么可以直接删除该规则了,如果没包含,就加入到多部门的DEPT_ID的IN LIST中。
|
|
||||||
deptIdSet.add(deptId);
|
|
||||||
ruleMap.remove(DataPermRuleType.TYPE_DEPT_AND_CHILD_DEPT);
|
|
||||||
}
|
|
||||||
// 需要与仅仅当前部门规则进行合并。
|
|
||||||
if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_ONLY)) {
|
|
||||||
if (deptIdSet.contains(deptId)) {
|
|
||||||
ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StringUtils.join(deptIdSet, ',');
|
|
||||||
}
|
|
||||||
|
|
||||||
private String processMultiDept(Map<Integer, List<SysDataPerm>> ruleMap, Long deptId) {
|
|
||||||
List<SysDataPerm> customDeptList = ruleMap.get(DataPermRuleType.TYPE_CUSTOM_DEPT_LIST);
|
|
||||||
if (customDeptList == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Set<Long> deptIdSet = new HashSet<>();
|
|
||||||
for (SysDataPerm customDept : customDeptList) {
|
|
||||||
deptIdSet.addAll(Arrays.stream(StringUtils.split(
|
|
||||||
customDept.getDeptIdListString(), ",")).map(Long::valueOf).collect(Collectors.toSet()));
|
|
||||||
}
|
|
||||||
if (ruleMap.containsKey(DataPermRuleType.TYPE_DEPT_ONLY)) {
|
|
||||||
deptIdSet.add(deptId);
|
|
||||||
ruleMap.remove(DataPermRuleType.TYPE_DEPT_ONLY);
|
|
||||||
}
|
|
||||||
return StringUtils.join(deptIdSet, ',');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加用户和数据权限之间的多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限Id。
|
|
||||||
* @param userIdSet 关联的用户Id列表。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public void addDataPermUserList(Long dataPermId, Set<Long> userIdSet) {
|
|
||||||
for (Long userId : userIdSet) {
|
|
||||||
SysDataPermUser dataPermUser = new SysDataPermUser();
|
|
||||||
dataPermUser.setDataPermId(dataPermId);
|
|
||||||
dataPermUser.setUserId(userId);
|
|
||||||
sysDataPermUserMapper.insert(dataPermUser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除用户和数据权限之间的多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param dataPermId 数据权限主键Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean removeDataPermUser(Long dataPermId, Long userId) {
|
|
||||||
SysDataPermUser dataPermUser = new SysDataPermUser();
|
|
||||||
dataPermUser.setDataPermId(dataPermId);
|
|
||||||
dataPermUser.setUserId(userId);
|
|
||||||
return sysDataPermUserMapper.delete(new QueryWrapper<>(dataPermUser)) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证数据权限对象关联菜单数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param dataPerm 数据权限关对象。
|
|
||||||
* @param deptIdListString 与数据权限关联的部门Id列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(SysDataPerm dataPerm, String deptIdListString) {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
if (dataPerm.getRuleType() == DataPermRuleType.TYPE_MULTI_DEPT_AND_CHILD_DEPT
|
|
||||||
|| dataPerm.getRuleType() == DataPermRuleType.TYPE_CUSTOM_DEPT_LIST) {
|
|
||||||
if (StringUtils.isBlank(deptIdListString)) {
|
|
||||||
return CallResult.error("数据验证失败,部门列表不能为空!");
|
|
||||||
}
|
|
||||||
Set<Long> deptIdSet = Arrays.stream(StringUtils.split(
|
|
||||||
deptIdListString, ",")).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (!sysDeptService.existAllPrimaryKeys(deptIdSet)) {
|
|
||||||
return CallResult.error("数据验证失败,存在不合法的部门数据,请刷新后重试!");
|
|
||||||
}
|
|
||||||
jsonObject.put("deptIdSet", deptIdSet);
|
|
||||||
}
|
|
||||||
return CallResult.ok(jsonObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void insertRelationData(SysDataPerm dataPerm, Set<Long> deptIdSet) {
|
|
||||||
if (CollectionUtils.isNotEmpty(deptIdSet)) {
|
|
||||||
for (Long deptId : deptIdSet) {
|
|
||||||
SysDataPermDept dataPermDept = new SysDataPermDept();
|
|
||||||
dataPermDept.setDataPermId(dataPerm.getDataPermId());
|
|
||||||
dataPermDept.setDeptId(deptId);
|
|
||||||
sysDataPermDeptMapper.insert(dataPermDept);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.webadmin.upms.service.*;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.*;
|
|
||||||
import com.orangeforms.webadmin.upms.model.*;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.constant.GlobalDeletedFlag;
|
|
||||||
import com.orangeforms.common.core.object.MyRelationParam;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门管理数据操作服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sysDeptService")
|
|
||||||
public class SysDeptServiceImpl extends BaseService<SysDept, Long> implements SysDeptService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysDeptMapper sysDeptMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysDeptRelationMapper sysDeptRelationMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysUserService sysUserService;
|
|
||||||
@Autowired
|
|
||||||
private SysDataPermDeptMapper sysDataPermDeptMapper;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回当前Service的主表Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主表Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<SysDept> mapper() {
|
|
||||||
return sysDeptMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的部门对象。
|
|
||||||
*
|
|
||||||
* @param sysDept 新增的部门对象。
|
|
||||||
* @param parentSysDept 上级部门对象。
|
|
||||||
* @return 新增后的部门对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public SysDept saveNew(SysDept sysDept, SysDept parentSysDept) {
|
|
||||||
sysDept.setDeptId(idGenerator.nextLongId());
|
|
||||||
sysDept.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
|
||||||
MyModelUtil.fillCommonsForInsert(sysDept);
|
|
||||||
sysDeptMapper.insert(sysDept);
|
|
||||||
// 同步插入部门关联关系数据
|
|
||||||
if (parentSysDept == null) {
|
|
||||||
sysDeptRelationMapper.insert(new SysDeptRelation(sysDept.getDeptId(), sysDept.getDeptId()));
|
|
||||||
} else {
|
|
||||||
sysDeptRelationMapper.insertParentList(parentSysDept.getDeptId(), sysDept.getDeptId());
|
|
||||||
}
|
|
||||||
return sysDept;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新部门对象。
|
|
||||||
*
|
|
||||||
* @param sysDept 更新的部门对象。
|
|
||||||
* @param originalSysDept 原有的部门对象。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(SysDept sysDept, SysDept originalSysDept) {
|
|
||||||
MyModelUtil.fillCommonsForUpdate(sysDept, originalSysDept);
|
|
||||||
UpdateWrapper<SysDept> uw = this.createUpdateQueryForNullValue(sysDept, sysDept.getDeptId());
|
|
||||||
if (sysDeptMapper.update(sysDept, uw) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ObjectUtils.notEqual(sysDept.getParentId(), originalSysDept.getParentId())) {
|
|
||||||
this.updateParentRelation(sysDept, originalSysDept);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateParentRelation(SysDept sysDept, SysDept originalSysDept) {
|
|
||||||
// 1. 在删除当前部门与原有父部门的关联关系之前,先将原有的所有父部门Id缓存。
|
|
||||||
List<Long> originalParentIdList = new LinkedList<>();
|
|
||||||
if (originalSysDept.getParentId() != null) {
|
|
||||||
SysDept originalParentDept = getById(originalSysDept.getParentId());
|
|
||||||
while (originalParentDept != null) {
|
|
||||||
originalParentIdList.add(originalParentDept.getDeptId());
|
|
||||||
if (originalParentDept.getParentId() == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
originalParentDept = getById(originalParentDept.getParentId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 删除其子部门与其原有父部门之间的关联关系。
|
|
||||||
for (Long parentDeptId : originalParentIdList) {
|
|
||||||
sysDeptRelationMapper.removeBetweenChildrenAndParents(parentDeptId, sysDept.getDeptId());
|
|
||||||
}
|
|
||||||
// 2. 将当前部门与原有的父部门列表解除关系。
|
|
||||||
SysDeptRelation filter = new SysDeptRelation();
|
|
||||||
filter.setDeptId(sysDept.getDeptId());
|
|
||||||
sysDeptRelationMapper.delete(new QueryWrapper<>(filter));
|
|
||||||
// 3. 将当前部门和新的父部门列表建立关联关系。
|
|
||||||
// 在插入与新父部门的关联关系
|
|
||||||
List<SysDeptRelation> deptRelationList = new LinkedList<>();
|
|
||||||
// 先插入自己和自己的关系。
|
|
||||||
deptRelationList.add(new SysDeptRelation(sysDept.getDeptId(), sysDept.getDeptId()));
|
|
||||||
SysDept parentSysDept = null;
|
|
||||||
if (sysDept.getParentId() != null) {
|
|
||||||
parentSysDept = getById(sysDept.getParentId());
|
|
||||||
}
|
|
||||||
List<Long> newParentIdList = new LinkedList<>();
|
|
||||||
// 再插入直接父部门,以及父部门的父部门,并向上以此类推。
|
|
||||||
while (parentSysDept != null) {
|
|
||||||
newParentIdList.add(parentSysDept.getDeptId());
|
|
||||||
deptRelationList.add(
|
|
||||||
new SysDeptRelation(parentSysDept.getDeptId(), sysDept.getDeptId()));
|
|
||||||
if (parentSysDept.getParentId() == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
parentSysDept = getById(parentSysDept.getParentId());
|
|
||||||
}
|
|
||||||
sysDeptRelationMapper.insertList(deptRelationList);
|
|
||||||
// 4. 将当前部门的子部门与其新的父部门建立关联关系
|
|
||||||
QueryWrapper<SysDeptRelation> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq(MyModelUtil.mapToColumnName("parentDeptId", SysDeptRelation.class), sysDept.getDeptId());
|
|
||||||
queryWrapper.ne(MyModelUtil.mapToColumnName("deptId", SysDeptRelation.class), sysDept.getDeptId());
|
|
||||||
List<SysDeptRelation> childRelationList = sysDeptRelationMapper.selectList(queryWrapper);
|
|
||||||
List<SysDeptRelation> newChildrenAndParentList = new LinkedList<>();
|
|
||||||
for (Long newParentId : newParentIdList) {
|
|
||||||
for (SysDeptRelation childDeptRelation : childRelationList) {
|
|
||||||
newChildrenAndParentList.add(new SysDeptRelation(newParentId, childDeptRelation.getDeptId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(newChildrenAndParentList)) {
|
|
||||||
sysDeptRelationMapper.insertList(newChildrenAndParentList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param deptId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long deptId) {
|
|
||||||
if (sysDeptMapper.deleteById(deptId) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 这里删除当前部门及其父部门的关联关系。
|
|
||||||
// 当前部门和子部门的关系无需在这里删除,因为包含子部门时不能删除父部门。
|
|
||||||
SysDeptRelation deptRelation = new SysDeptRelation();
|
|
||||||
deptRelation.setDeptId(deptId);
|
|
||||||
sysDeptRelationMapper.delete(new QueryWrapper<>(deptRelation));
|
|
||||||
SysDataPermDept dataPermDept = new SysDataPermDept();
|
|
||||||
dataPermDept.setDeptId(deptId);
|
|
||||||
sysDataPermDeptMapper.delete(new QueryWrapper<>(dataPermDept));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getSysDeptListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysDept> getSysDeptList(SysDept filter, String orderBy) {
|
|
||||||
return sysDeptMapper.getSysDeptList(filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getSysDeptList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysDept> getSysDeptListWithRelation(SysDept filter, String orderBy) {
|
|
||||||
List<SysDept> resultList = sysDeptMapper.getSysDeptList(filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断指定对象是否包含下级对象。
|
|
||||||
*
|
|
||||||
* @param deptId 主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasChildren(Long deptId) {
|
|
||||||
SysDept filter = new SysDept();
|
|
||||||
filter.setParentId(deptId);
|
|
||||||
return getCountByFilter(filter) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断指定部门Id是否包含用户对象。
|
|
||||||
*
|
|
||||||
* @param deptId 部门主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasChildrenUser(Long deptId) {
|
|
||||||
SysUser sysUser = new SysUser();
|
|
||||||
sysUser.setDeptId(deptId);
|
|
||||||
return sysUserService.getCountByFilter(sysUser) > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,331 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysMenuMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysMenuPermCodeMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysRoleMenuMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenu;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenuPermCode;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysRoleMenu;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysMenuType;
|
|
||||||
import com.orangeforms.webadmin.upms.model.constant.SysOnlineMenuPermType;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysMenuService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermCodeService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单数据服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sysMenuService")
|
|
||||||
public class SysMenuServiceImpl extends BaseService<SysMenu, Long> implements SysMenuService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysMenuMapper sysMenuMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysRoleMenuMapper sysRoleMenuMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysMenuPermCodeMapper sysMenuPermCodeMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysPermCodeService sysPermCodeService;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回主对象的Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主对象的Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<SysMenu> mapper() {
|
|
||||||
return sysMenuMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的菜单对象。
|
|
||||||
*
|
|
||||||
* @param sysMenu 新增的菜单对象。
|
|
||||||
* @param permCodeIdSet 权限字Id列表。
|
|
||||||
* @return 新增后的菜单对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public SysMenu saveNew(SysMenu sysMenu, Set<Long> permCodeIdSet) {
|
|
||||||
sysMenu.setMenuId(idGenerator.nextLongId());
|
|
||||||
MyModelUtil.fillCommonsForInsert(sysMenu);
|
|
||||||
sysMenuMapper.insert(sysMenu);
|
|
||||||
if (permCodeIdSet != null) {
|
|
||||||
for (Long permCodeId : permCodeIdSet) {
|
|
||||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
|
||||||
menuPermCode.setMenuId(sysMenu.getMenuId());
|
|
||||||
menuPermCode.setPermCodeId(permCodeId);
|
|
||||||
sysMenuPermCodeMapper.insert(menuPermCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 判断当前菜单是否为指向在线表单的菜单,并将根据约定,动态插入两个子菜单。
|
|
||||||
if (sysMenu.getOnlineFormId() != null) {
|
|
||||||
SysMenu viewSubMenu = new SysMenu();
|
|
||||||
viewSubMenu.setMenuId(idGenerator.nextLongId());
|
|
||||||
viewSubMenu.setParentId(sysMenu.getMenuId());
|
|
||||||
viewSubMenu.setMenuType(SysMenuType.TYPE_BUTTON);
|
|
||||||
viewSubMenu.setMenuName("查看");
|
|
||||||
viewSubMenu.setShowOrder(0);
|
|
||||||
viewSubMenu.setOnlineFormId(sysMenu.getOnlineFormId());
|
|
||||||
viewSubMenu.setOnlineMenuPermType(SysOnlineMenuPermType.TYPE_VIEW);
|
|
||||||
MyModelUtil.fillCommonsForInsert(viewSubMenu);
|
|
||||||
sysMenuMapper.insert(viewSubMenu);
|
|
||||||
SysMenu editSubMenu = new SysMenu();
|
|
||||||
editSubMenu.setMenuId(idGenerator.nextLongId());
|
|
||||||
editSubMenu.setParentId(sysMenu.getMenuId());
|
|
||||||
editSubMenu.setMenuType(SysMenuType.TYPE_BUTTON);
|
|
||||||
editSubMenu.setMenuName("编辑");
|
|
||||||
editSubMenu.setShowOrder(1);
|
|
||||||
editSubMenu.setOnlineFormId(sysMenu.getOnlineFormId());
|
|
||||||
editSubMenu.setOnlineMenuPermType(SysOnlineMenuPermType.TYPE_EDIT);
|
|
||||||
MyModelUtil.fillCommonsForInsert(editSubMenu);
|
|
||||||
sysMenuMapper.insert(editSubMenu);
|
|
||||||
}
|
|
||||||
return sysMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新菜单对象。
|
|
||||||
*
|
|
||||||
* @param sysMenu 更新的菜单对象。
|
|
||||||
* @param originalSysMenu 原有的菜单对象。
|
|
||||||
* @param permCodeIdSet 权限字Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(SysMenu sysMenu, SysMenu originalSysMenu, Set<Long> permCodeIdSet) {
|
|
||||||
MyModelUtil.fillCommonsForUpdate(sysMenu, originalSysMenu);
|
|
||||||
sysMenu.setMenuType(originalSysMenu.getMenuType());
|
|
||||||
UpdateWrapper<SysMenu> uw = this.createUpdateQueryForNullValue(sysMenu, sysMenu.getMenuId());
|
|
||||||
if (sysMenuMapper.update(sysMenu, uw) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysMenuPermCode deletedMenuPermCode = new SysMenuPermCode();
|
|
||||||
deletedMenuPermCode.setMenuId(sysMenu.getMenuId());
|
|
||||||
sysMenuPermCodeMapper.delete(new QueryWrapper<>(deletedMenuPermCode));
|
|
||||||
if (permCodeIdSet != null) {
|
|
||||||
for (Long permCodeId : permCodeIdSet) {
|
|
||||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
|
||||||
menuPermCode.setMenuId(sysMenu.getMenuId());
|
|
||||||
menuPermCode.setPermCodeId(permCodeId);
|
|
||||||
sysMenuPermCodeMapper.insert(menuPermCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 如果当前菜单的在线表单Id变化了,就需要同步更新他的内置子菜单也同步更新。
|
|
||||||
if (ObjectUtil.notEqual(originalSysMenu.getOnlineFormId(), sysMenu.getOnlineFormId())) {
|
|
||||||
SysMenu onlineSubMenu = new SysMenu();
|
|
||||||
onlineSubMenu.setOnlineFormId(sysMenu.getOnlineFormId());
|
|
||||||
sysMenuMapper.update(onlineSubMenu,
|
|
||||||
new QueryWrapper<SysMenu>().lambda().eq(SysMenu::getParentId, sysMenu.getMenuId()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定的菜单。
|
|
||||||
*
|
|
||||||
* @param menu 菜单对象。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(SysMenu menu) {
|
|
||||||
Long menuId = menu.getMenuId();
|
|
||||||
if (sysMenuMapper.deleteById(menuId) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
|
||||||
roleMenu.setMenuId(menuId);
|
|
||||||
sysRoleMenuMapper.delete(new QueryWrapper<>(roleMenu));
|
|
||||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
|
||||||
menuPermCode.setMenuId(menuId);
|
|
||||||
sysMenuPermCodeMapper.delete(new QueryWrapper<>(menuPermCode));
|
|
||||||
// 如果为指向在线表单的菜单,则连同删除子菜单
|
|
||||||
if (menu.getOnlineFormId() != null) {
|
|
||||||
sysMenuMapper.delete(new QueryWrapper<SysMenu>().lambda().eq(SysMenu::getParentId, menuId));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取全部菜单列表。
|
|
||||||
*
|
|
||||||
* @return 全部菜单列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<SysMenu> getAllMenuList() {
|
|
||||||
QueryWrapper<SysMenu> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.orderByAsc(this.safeMapToColumnName("showOrder"));
|
|
||||||
queryWrapper.in(this.safeMapToColumnName("menuType"),
|
|
||||||
Arrays.asList(SysMenuType.TYPE_MENU, SysMenuType.TYPE_DIRECTORY));
|
|
||||||
return sysMenuMapper.selectList(queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户Id的菜单列表,已去重。
|
|
||||||
*
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 用户关联的菜单列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<SysMenu> getMenuListByUserId(Long userId) {
|
|
||||||
List<SysMenu> menuList = sysMenuMapper.getMenuListByUserId(userId);
|
|
||||||
LinkedHashMap<Long, SysMenu> menuMap = new LinkedHashMap<>();
|
|
||||||
for (SysMenu menu : menuList) {
|
|
||||||
menuMap.put(menu.getMenuId(), menu);
|
|
||||||
}
|
|
||||||
return menuMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前菜单是否存在子菜单。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasChildren(Long menuId) {
|
|
||||||
SysMenu menu = new SysMenu();
|
|
||||||
menu.setParentId(menuId);
|
|
||||||
return this.getCountByFilter(menu) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证菜单对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysMenu 当前操作的对象。
|
|
||||||
* @param originalSysMenu 原有对象。
|
|
||||||
* @param permCodeIdListString 逗号分隔的权限Id列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu, String permCodeIdListString) {
|
|
||||||
// menu、ui fragment和button类型的menu不能没有parentId
|
|
||||||
if (sysMenu.getParentId() == null) {
|
|
||||||
if (sysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) {
|
|
||||||
return CallResult.error("数据验证失败,当前类型菜单项的上级菜单不能为空!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.needToVerify(sysMenu, originalSysMenu, SysMenu::getParentId)) {
|
|
||||||
String errorMessage = checkErrorOfNonDirectoryMenu(sysMenu);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return CallResult.error(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = null;
|
|
||||||
if (StringUtils.isNotBlank(permCodeIdListString)) {
|
|
||||||
Set<Long> permCodeIdSet = Arrays.stream(
|
|
||||||
permCodeIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (!sysPermCodeService.existAllPrimaryKeys(permCodeIdSet)) {
|
|
||||||
return CallResult.error("数据验证失败,存在不合法的权限字,请刷新后重试!");
|
|
||||||
}
|
|
||||||
jsonObject = new JSONObject();
|
|
||||||
jsonObject.put("permCodeIdSet", permCodeIdSet);
|
|
||||||
}
|
|
||||||
return CallResult.ok(jsonObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param url 权限资源地址过滤条件。
|
|
||||||
* @return 包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysPermListWithDetail(Long menuId, String url) {
|
|
||||||
return sysMenuMapper.getSysPermListWithDetail(menuId, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param menuId 菜单Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysUserListWithDetail(Long menuId, String loginName) {
|
|
||||||
return sysMenuMapper.getSysUserListWithDetail(menuId, loginName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定类型的所有在线表单的菜单。
|
|
||||||
*
|
|
||||||
* @param menuType 菜单类型,NULL则返回全部类型。
|
|
||||||
* @return 在线表单关联的菜单列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysMenu> getAllOnlineMenuList(Integer menuType) {
|
|
||||||
LambdaQueryWrapper<SysMenu> queryWrapper =
|
|
||||||
new QueryWrapper<SysMenu>().lambda().isNotNull(SysMenu::getOnlineFormId);
|
|
||||||
if (menuType != null) {
|
|
||||||
queryWrapper.eq(SysMenu::getMenuType, menuType);
|
|
||||||
}
|
|
||||||
return sysMenuMapper.selectList(queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前用户有权访问的在线表单菜单,仅返回类型为BUTTON的菜单。
|
|
||||||
*
|
|
||||||
* @param userId 指定的用户。
|
|
||||||
* @param menuType 菜单类型,NULL则返回全部类型。
|
|
||||||
* @return 在线表单关联的菜单列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysMenu> getOnlineMenuListByUserId(Long userId, Integer menuType) {
|
|
||||||
return sysMenuMapper.getOnlineMenuListByUserId(userId, menuType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String checkErrorOfNonDirectoryMenu(SysMenu sysMenu) {
|
|
||||||
// 判断父节点是否存在
|
|
||||||
SysMenu parentSysMenu = getById(sysMenu.getParentId());
|
|
||||||
if (parentSysMenu == null) {
|
|
||||||
return "数据验证失败,关联的上级菜单并不存在,请刷新后重试!";
|
|
||||||
}
|
|
||||||
// 逐个判断每种类型的菜单,他的父菜单的合法性,先从目录类型和菜单类型开始
|
|
||||||
if (sysMenu.getMenuType() == SysMenuType.TYPE_DIRECTORY
|
|
||||||
|| sysMenu.getMenuType() == SysMenuType.TYPE_MENU) {
|
|
||||||
// 他们的上级只能是目录
|
|
||||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) {
|
|
||||||
return "数据验证失败,当前类型菜单项的上级菜单只能是目录类型!";
|
|
||||||
}
|
|
||||||
} else if (sysMenu.getMenuType() == SysMenuType.TYPE_UI_FRAGMENT) {
|
|
||||||
// ui fragment的上级只能是menu类型
|
|
||||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU) {
|
|
||||||
return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和按钮类型!";
|
|
||||||
}
|
|
||||||
} else if (sysMenu.getMenuType() == SysMenuType.TYPE_BUTTON) {
|
|
||||||
// button的上级只能是menu和ui fragment
|
|
||||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU
|
|
||||||
&& parentSysMenu.getMenuType() != SysMenuType.TYPE_UI_FRAGMENT) {
|
|
||||||
return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和UI片段类型!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysMenuPermCodeMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysPermCodeMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysPermCodePermMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysMenuPermCode;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCode;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCodePerm;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermCodeService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字数据服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sysPermCodeService")
|
|
||||||
public class SysPermCodeServiceImpl extends BaseService<SysPermCode, Long> implements SysPermCodeService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermCodeMapper sysPermCodeMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysPermCodePermMapper sysPermCodePermMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysMenuPermCodeMapper sysMenuPermCodeMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysPermService sysPermService;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回主对象的Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主对象的Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<SysPermCode> mapper() {
|
|
||||||
return sysPermCodeMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指定用户的权限字列表,已去重。
|
|
||||||
*
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 用户关联的权限字列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<String> getPermCodeListByUserId(Long userId) {
|
|
||||||
List<String> permCodeList = sysPermCodeMapper.getPermCodeListByUserId(userId);
|
|
||||||
return new HashSet<>(permCodeList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有权限字数据列表,已去重。
|
|
||||||
*
|
|
||||||
* @return 全部权限字列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<String> getAllPermCodeList() {
|
|
||||||
List<SysPermCode> permCodeList = this.getAllList();
|
|
||||||
return permCodeList.stream().map(SysPermCode::getPermCode).collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的权限字对象。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 新增的权限字对象。
|
|
||||||
* @param permIdSet 权限资源Id列表。
|
|
||||||
* @return 新增后的权限字对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public SysPermCode saveNew(SysPermCode sysPermCode, Set<Long> permIdSet) {
|
|
||||||
sysPermCode.setPermCodeId(idGenerator.nextLongId());
|
|
||||||
MyModelUtil.fillCommonsForInsert(sysPermCode);
|
|
||||||
sysPermCodeMapper.insert(sysPermCode);
|
|
||||||
if (permIdSet != null) {
|
|
||||||
for (Long permId : permIdSet) {
|
|
||||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
|
||||||
permCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
|
||||||
permCodePerm.setPermId(permId);
|
|
||||||
sysPermCodePermMapper.insert(permCodePerm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sysPermCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限字对象。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 更新的权限字对象。
|
|
||||||
* @param originalSysPermCode 原有的权限字对象。
|
|
||||||
* @param permIdSet 权限资源Id列表。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(SysPermCode sysPermCode, SysPermCode originalSysPermCode, Set<Long> permIdSet) {
|
|
||||||
MyModelUtil.fillCommonsForUpdate(sysPermCode, originalSysPermCode);
|
|
||||||
sysPermCode.setParentId(originalSysPermCode.getParentId());
|
|
||||||
UpdateWrapper<SysPermCode> uw =
|
|
||||||
this.createUpdateQueryForNullValue(sysPermCode, sysPermCode.getPermCodeId());
|
|
||||||
if (sysPermCodeMapper.update(sysPermCode, uw) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysPermCodePerm deletedPermCodePerm = new SysPermCodePerm();
|
|
||||||
deletedPermCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
|
||||||
sysPermCodePermMapper.delete(new QueryWrapper<>(deletedPermCodePerm));
|
|
||||||
if (permIdSet != null) {
|
|
||||||
for (Long permId : permIdSet) {
|
|
||||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
|
||||||
permCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
|
||||||
permCodePerm.setPermId(permId);
|
|
||||||
sysPermCodePermMapper.insert(permCodePerm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定的权限字。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long permCodeId) {
|
|
||||||
if (sysPermCodeMapper.deleteById(permCodeId) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
|
||||||
menuPermCode.setPermCodeId(permCodeId);
|
|
||||||
sysMenuPermCodeMapper.delete(new QueryWrapper<>(menuPermCode));
|
|
||||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
|
||||||
permCodePerm.setPermCodeId(permCodeId);
|
|
||||||
sysPermCodePermMapper.delete(new QueryWrapper<>(permCodePerm));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前权限字是否存在下级权限字对象。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasChildren(Long permCodeId) {
|
|
||||||
SysPermCode permCode = new SysPermCode();
|
|
||||||
permCode.setParentId(permCodeId);
|
|
||||||
return this.getCountByFilter(permCode) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证权限字对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysPermCode 当前操作的对象。
|
|
||||||
* @param originalSysPermCode 原有对象。
|
|
||||||
* @param permIdListString 逗号分隔的权限资源Id列表。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(
|
|
||||||
SysPermCode sysPermCode, SysPermCode originalSysPermCode, String permIdListString) {
|
|
||||||
if (this.needToVerify(sysPermCode, originalSysPermCode, SysPermCode::getParentId)) {
|
|
||||||
if (getById(sysPermCode.getParentId()) == null) {
|
|
||||||
return CallResult.error("数据验证失败,关联的上级权限字并不存在,请刷新后重试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = null;
|
|
||||||
if (StringUtils.isNotBlank(permIdListString)) {
|
|
||||||
Set<Long> permIdSet = Arrays.stream(
|
|
||||||
permIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
|
||||||
if (!sysPermService.existAllPrimaryKeys(permIdSet)) {
|
|
||||||
return CallResult.error("数据验证失败,存在不合法的权限资源,请刷新后重试!");
|
|
||||||
}
|
|
||||||
jsonObject = new JSONObject();
|
|
||||||
jsonObject.put("permIdSet", permIdSet);
|
|
||||||
}
|
|
||||||
return CallResult.ok(jsonObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysUserListWithDetail(Long permCodeId, String loginName) {
|
|
||||||
return sysPermCodeMapper.getSysUserListWithDetail(permCodeId, loginName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permCodeId 权限字Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 包含从权限字到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysRoleListWithDetail(Long permCodeId, String roleName) {
|
|
||||||
return sysPermCodeMapper.getSysRoleListWithDetail(permCodeId, roleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service.impl;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysPermModuleMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPerm;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermModule;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermModuleService;
|
|
||||||
import com.orangeforms.webadmin.upms.service.SysPermService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源模块数据服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sysPermModuleService")
|
|
||||||
public class SysPermModuleServiceImpl extends BaseService<SysPermModule, Long> implements SysPermModuleService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermModuleMapper sysPermModuleMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysPermService sysPermService;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回主对象的Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主对象的Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<SysPermModule> mapper() {
|
|
||||||
return sysPermModuleMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的权限资源模块对象。
|
|
||||||
*
|
|
||||||
* @param sysPermModule 新增的权限资源模块对象。
|
|
||||||
* @return 新增后的权限资源模块对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public SysPermModule saveNew(SysPermModule sysPermModule) {
|
|
||||||
sysPermModule.setModuleId(idGenerator.nextLongId());
|
|
||||||
MyModelUtil.fillCommonsForInsert(sysPermModule);
|
|
||||||
sysPermModuleMapper.insert(sysPermModule);
|
|
||||||
return sysPermModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限资源模块对象。
|
|
||||||
*
|
|
||||||
* @param sysPermModule 更新的权限资源模块对象。
|
|
||||||
* @param originalSysPermModule 原有的权限资源模块对象。
|
|
||||||
* @return 更新成功返回true,否则false
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(SysPermModule sysPermModule, SysPermModule originalSysPermModule) {
|
|
||||||
MyModelUtil.fillCommonsForUpdate(sysPermModule, originalSysPermModule);
|
|
||||||
return sysPermModuleMapper.updateById(sysPermModule) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定的权限资源模块。
|
|
||||||
*
|
|
||||||
* @param moduleId 权限资源模块主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long moduleId) {
|
|
||||||
return sysPermModuleMapper.deleteById(moduleId) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取权限模块资源及其关联的权限资源列表。
|
|
||||||
*
|
|
||||||
* @return 权限资源模块及其关联的权限资源列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysPermModule> getPermModuleAndPermList() {
|
|
||||||
return sysPermModuleMapper.getPermModuleAndPermList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否存在下级权限资源模块。
|
|
||||||
*
|
|
||||||
* @param moduleId 权限资源模块主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasChildren(Long moduleId) {
|
|
||||||
SysPermModule permModule = new SysPermModule();
|
|
||||||
permModule.setParentId(moduleId);
|
|
||||||
return this.getCountByFilter(permModule) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否存在权限数据。
|
|
||||||
*
|
|
||||||
* @param moduleId 权限资源模块主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasModulePerms(Long moduleId) {
|
|
||||||
SysPerm filter = new SysPerm();
|
|
||||||
filter.setModuleId(moduleId);
|
|
||||||
return sysPermService.getCountByFilter(filter) > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
package com.orangeforms.webadmin.upms.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.object.MyRelationParam;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.util.RedisKeyUtil;
|
|
||||||
import com.orangeforms.webadmin.config.ApplicationConfig;
|
|
||||||
import com.orangeforms.webadmin.upms.service.*;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysPermCodePermMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.dao.SysPermMapper;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPerm;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermCodePerm;
|
|
||||||
import com.orangeforms.webadmin.upms.model.SysPermModule;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.redisson.api.RSet;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限资源数据服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2022-02-20
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("sysPermService")
|
|
||||||
public class SysPermServiceImpl extends BaseService<SysPerm, Long> implements SysPermService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermMapper sysPermMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysPermCodePermMapper sysPermCodePermMapper;
|
|
||||||
@Autowired
|
|
||||||
private SysPermModuleService sysPermModuleService;
|
|
||||||
@Autowired
|
|
||||||
private SysUserService sysUserService;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig applicationConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回主对象的Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主对象的Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<SysPerm> mapper() {
|
|
||||||
return sysPermMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增的权限资源对象。
|
|
||||||
*
|
|
||||||
* @param perm 新增的权限资源对象。
|
|
||||||
* @return 新增后的权限资源对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public SysPerm saveNew(SysPerm perm) {
|
|
||||||
perm.setPermId(idGenerator.nextLongId());
|
|
||||||
MyModelUtil.fillCommonsForInsert(perm);
|
|
||||||
sysPermMapper.insert(perm);
|
|
||||||
return perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新权限资源对象。
|
|
||||||
*
|
|
||||||
* @param perm 更新的权限资源对象。
|
|
||||||
* @param originalPerm 原有的权限资源对象。
|
|
||||||
* @return 更新成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(SysPerm perm, SysPerm originalPerm) {
|
|
||||||
MyModelUtil.fillCommonsForUpdate(perm, originalPerm);
|
|
||||||
return sysPermMapper.updateById(perm) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除权限资源。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源主键Id。
|
|
||||||
* @return 删除成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long permId) {
|
|
||||||
if (sysPermMapper.deleteById(permId) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
|
||||||
permCodePerm.setPermId(permId);
|
|
||||||
sysPermCodePermMapper.delete(new QueryWrapper<>(permCodePerm));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取权限数据列表。
|
|
||||||
*
|
|
||||||
* @param sysPermFilter 过滤对象。
|
|
||||||
* @return 权限列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysPerm> getPermListWithRelation(SysPerm sysPermFilter) {
|
|
||||||
QueryWrapper<SysPerm> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.orderByAsc(this.safeMapToColumnName("showOrder"));
|
|
||||||
queryWrapper.eq(ObjectUtil.isNotNull(sysPermFilter.getModuleId()),
|
|
||||||
this.safeMapToColumnName("moduleId"), sysPermFilter.getModuleId());
|
|
||||||
queryWrapper.like(ObjectUtil.isNotNull(sysPermFilter.getUrl()),
|
|
||||||
this.safeMapToColumnName("url"), "%" + sysPermFilter.getUrl() + "%");
|
|
||||||
List<SysPerm> permList = sysPermMapper.selectList(queryWrapper);
|
|
||||||
// 这里因为权限只有字典数据,所以仅仅做字典关联。
|
|
||||||
this.buildRelationForDataList(permList, MyRelationParam.dictOnly());
|
|
||||||
return permList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定用户的指定会话的权限集合存入缓存。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
* @param userId 用户主键Id。
|
|
||||||
* @return 查询并缓存后的权限集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<String> putUserSysPermCache(String sessionId, Long userId) {
|
|
||||||
Collection<String> permList = this.getPermListByUserId(userId);
|
|
||||||
if (CollectionUtils.isEmpty(permList)) {
|
|
||||||
return permList;
|
|
||||||
}
|
|
||||||
String sessionPermKey = RedisKeyUtil.makeSessionPermIdKey(sessionId);
|
|
||||||
RSet<String> redisPermSet = redissonClient.getSet(sessionPermKey);
|
|
||||||
redisPermSet.addAll(permList.stream().map(Object::toString).collect(Collectors.toSet()));
|
|
||||||
redisPermSet.expire(applicationConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS);
|
|
||||||
return permList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 把在线表单的权限URL集合,存放到权限URL的缓存中。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
* @param permUrlSet URL集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void putOnlinePermToCache(String sessionId, Set<String> permUrlSet) {
|
|
||||||
String sessionPermKey = RedisKeyUtil.makeSessionPermIdKey(sessionId);
|
|
||||||
redissonClient.getSet(sessionPermKey).addAll(permUrlSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定会话的权限集合从缓存中移除。
|
|
||||||
*
|
|
||||||
* @param sessionId 会话Id。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void removeUserSysPermCache(String sessionId) {
|
|
||||||
String sessionPermKey = RedisKeyUtil.makeSessionPermIdKey(sessionId);
|
|
||||||
redissonClient.getSet(sessionPermKey).deleteAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取与指定用户关联的权限资源列表,已去重。
|
|
||||||
*
|
|
||||||
* @param userId 关联的用户主键Id。
|
|
||||||
* @return 与指定用户Id关联的权限资源列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<String> getPermListByUserId(Long userId) {
|
|
||||||
List<String> urlList = sysPermMapper.getPermListByUserId(userId);
|
|
||||||
return new HashSet<>(urlList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证权限资源对象关联的数据是否都合法。
|
|
||||||
*
|
|
||||||
* @param sysPerm 当前操作的对象。
|
|
||||||
* @param originalSysPerm 原有对象。
|
|
||||||
* @return 验证结果。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(SysPerm sysPerm, SysPerm originalSysPerm) {
|
|
||||||
if (this.needToVerify(sysPerm, originalSysPerm, SysPerm::getModuleId)) {
|
|
||||||
SysPermModule permModule = sysPermModuleService.getById(sysPerm.getModuleId());
|
|
||||||
if (permModule == null) {
|
|
||||||
return CallResult.error("数据验证失败,关联的权限模块Id并不存在,请刷新后重试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CallResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param loginName 登录名。
|
|
||||||
* @return 包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysUserListWithDetail(Long permId, String loginName) {
|
|
||||||
return sysPermMapper.getSysUserListWithDetail(permId, loginName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param roleName 角色名。
|
|
||||||
* @return 包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysRoleListWithDetail(Long permId, String roleName) {
|
|
||||||
return sysPermMapper.getSysRoleListWithDetail(permId, roleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
|
||||||
*
|
|
||||||
* @param permId 权限资源Id。
|
|
||||||
* @param menuName 菜单名。
|
|
||||||
* @return 包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Object>> getSysMenuListWithDetail(Long permId, String menuName) {
|
|
||||||
return sysPermMapper.getSysMenuListWithDetail(permId, menuName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user