删除文件 orange-demo-flowable

This commit is contained in:
orange-form
2024-07-05 14:32:13 +00:00
committed by Gitee
parent b3b5379110
commit e01c15c0fd
941 changed files with 0 additions and 232662 deletions

View File

@@ -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/

View File

@@ -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)

View File

@@ -1,103 +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>DemoFlow</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-online-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>common-flow-online</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>

View File

@@ -1,23 +0,0 @@
package com.orangeforms.webadmin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
/**
* 应用服务启动类。
*
* @author Jerry
* @date 2021-06-06
*/
@EnableAsync
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@ComponentScan("com.orangeforms")
public class WebAdminApplication {
public static void main(String[] args) {
SpringApplication.run(WebAdminApplication.class, args);
}
}

View File

@@ -1,74 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import io.swagger.annotations.Api;
import cn.jimmyshi.beanquery.BeanQuery;
import com.orangeforms.webadmin.app.model.AreaCode;
import com.orangeforms.webadmin.app.service.AreaCodeService;
import com.orangeforms.common.core.object.ResponseResult;
import com.orangeforms.common.core.annotation.MyRequestBody;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
* 行政区划数据访问接口类。
*
* @author Jerry
* @date 2021-06-06
*/
@Api(tags = "行政区划数据访问接口")
@RestController
@RequestMapping("/admin/app/areaCode")
public class AreaCodeController {
@Autowired
private AreaCodeService areaCodeService;
/**
* 按照字典的形式返回行政区划列表。
*
* @return 字典形式的行政区划列表。
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict() {
List<AreaCode> resultList = areaCodeService.getAllListFromCache();
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
}
/**
* 根据上级行政区划Id获取其下级行政区划列表。
*
* @param parentId 上级行政区划Id。
* @return 按照字典的形式返回下级行政区划列表。
*/
@GetMapping("/listDictByParentId")
public ResponseResult<List<Map<String, Object>>> listDictByParentId(@RequestParam(required = false) Long parentId) {
Collection<AreaCode> resultList = areaCodeService.getListByParentId(parentId);
if (CollectionUtils.isEmpty(resultList)) {
return ResponseResult.success(new LinkedList<>());
}
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "areaId as id", "areaName 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<AreaCode> resultList = areaCodeService.getInList(new HashSet<>(dictIds));
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
}
}

View File

@@ -1,13 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.app.model.AreaCode;
/**
* 行政区划数据操作访问接口。
*
* @author Jerry
* @date 2021-06-06
*/
public interface AreaCodeMapper extends BaseDaoMapper<AreaCode> {
}

View File

@@ -1,10 +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.app.dao.AreaCodeMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.app.model.AreaCode">
<id column="area_id" jdbcType="BIGINT" property="areaId"/>
<result column="area_name" jdbcType="VARCHAR" property="areaName"/>
<result column="area_level" jdbcType="INTEGER" property="areaLevel"/>
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
</resultMap>
</mapper>

View File

@@ -1,39 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 行政区划实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@Data
@TableName(value = "zz_area_code")
public class AreaCode {
/**
* 行政区划主键Id
*/
@TableId(value = "area_id")
private Long areaId;
/**
* 行政区划名称
*/
@TableField(value = "area_name")
private String areaName;
/**
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
*/
@TableField(value = "area_level")
private Integer areaLevel;
/**
* 父级行政区划Id
*/
@TableField(value = "parent_id")
private Long parentId;
}

View File

@@ -1,23 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.common.core.base.service.IBaseDictService;
import com.orangeforms.webadmin.app.model.AreaCode;
import java.util.Collection;
/**
* 行政区划的Service接口。
*
* @author Jerry
* @date 2021-06-06
*/
public interface AreaCodeService extends IBaseDictService<AreaCode, Long> {
/**
* 根据上级行政区划Id获取其下级行政区划列表。
*
* @param parentId 上级行政区划Id。
* @return 下级行政区划列表。
*/
Collection<AreaCode> getListByParentId(Long parentId);
}

View File

@@ -1,52 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import com.orangeforms.webadmin.app.service.AreaCodeService;
import com.orangeforms.webadmin.app.dao.AreaCodeMapper;
import com.orangeforms.webadmin.app.model.AreaCode;
import com.orangeforms.common.core.cache.MapTreeDictionaryCache;
import com.orangeforms.common.core.base.service.BaseDictService;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.Collection;
/**
* 行政区划的Service类。
*
* @author Jerry
* @date 2021-06-06
*/
@Service("areaCodeService")
public class AreaCodeServiceImpl extends BaseDictService<AreaCode, Long> implements AreaCodeService {
@Autowired
private AreaCodeMapper areaCodeMapper;
public AreaCodeServiceImpl() {
super();
this.dictionaryCache = MapTreeDictionaryCache.create(AreaCode::getAreaId, AreaCode::getParentId);
}
@PostConstruct
public void init() {
this.reloadCachedData(true);
}
@Override
protected BaseDaoMapper<AreaCode> mapper() {
return areaCodeMapper;
}
/**
* 根据上级行政区划Id获取其下级行政区划列表。
*
* @param parentId 上级行政区划Id。
* @return 下级行政区划列表。
*/
@Override
public Collection<AreaCode> getListByParentId(Long parentId) {
return ((MapTreeDictionaryCache<Long, AreaCode>) dictionaryCache).getListByParentId(parentId);
}
}

View File

@@ -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);
}
}

View File

@@ -1,151 +0,0 @@
package com.orangeforms.webadmin.app.util;
import cn.hutool.core.collection.CollUtil;
import com.orangeforms.common.flow.util.BaseFlowIdentityExtHelper;
import com.orangeforms.common.flow.util.FlowCustomExtFactory;
import com.orangeforms.webadmin.upms.model.SysDept;
import com.orangeforms.webadmin.upms.model.SysUser;
import com.orangeforms.webadmin.upms.model.constant.SysUserStatus;
import com.orangeforms.webadmin.upms.model.SysDeptPost;
import com.orangeforms.webadmin.upms.service.SysDeptService;
import com.orangeforms.webadmin.upms.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.stream.Collectors;
/**
* 为流程提供所需的用户身份相关的等扩展信息的帮助类。
*
* @author Jerry
* @date 2021-06-06
*/
@Slf4j
@Component
public class FlowIdentityExtHelper implements BaseFlowIdentityExtHelper {
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysUserService sysUserService;
@Autowired
private FlowCustomExtFactory flowCustomExtFactory;
@PostConstruct
public void doRegister() {
flowCustomExtFactory.registerFlowIdentityExtHelper(this);
}
@Override
public Long getLeaderDeptPostId(Long deptId) {
List<Long> deptPostIdList = sysDeptService.getLeaderDeptPostIdList(deptId);
return CollUtil.isEmpty(deptPostIdList) ? null : deptPostIdList.get(0);
}
@Override
public Long getUpLeaderDeptPostId(Long deptId) {
List<Long> deptPostIdList = sysDeptService.getUpLeaderDeptPostIdList(deptId);
return CollUtil.isEmpty(deptPostIdList) ? null : deptPostIdList.get(0);
}
@Override
public Map<String, String> getDeptPostIdMap(Long deptId, Set<String> postIdSet) {
Set<Long> postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet());
List<SysDeptPost> deptPostList = sysDeptService.getSysDeptPostList(deptId, postIdSet2);
if (CollUtil.isEmpty(deptPostList)) {
return null;
}
Map<String, String> resultMap = new HashMap<>(deptPostList.size());
deptPostList.forEach(sysDeptPost ->
resultMap.put(sysDeptPost.getPostId().toString(), sysDeptPost.getDeptPostId().toString()));
return resultMap;
}
@Override
public Map<String, String> getUpDeptPostIdMap(Long deptId, Set<String> postIdSet) {
SysDept sysDept = sysDeptService.getById(deptId);
if (sysDept == null || sysDept.getParentId() == null) {
return null;
}
return getDeptPostIdMap(sysDept.getParentId(), postIdSet);
}
@Override
public Set<String> getUsernameListByRoleIds(Set<String> roleIdSet) {
Set<String> usernameSet = new HashSet<>();
Set<Long> roleIdSet2 = roleIdSet.stream().map(Long::valueOf).collect(Collectors.toSet());
SysUser filter = new SysUser();
filter.setUserStatus(SysUserStatus.STATUS_NORMAL);
for (Long roleId : roleIdSet2) {
List<SysUser> userList = sysUserService.getSysUserListByRoleId(roleId, filter, null);
this.extractAndAppendUsernameList(usernameSet, userList);
}
return usernameSet;
}
@Override
public Set<String> getUsernameListByDeptIds(Set<String> deptIdSet) {
Set<String> usernameSet = new HashSet<>();
Set<Long> deptIdSet2 = deptIdSet.stream().map(Long::valueOf).collect(Collectors.toSet());
for (Long deptId : deptIdSet2) {
SysUser filter = new SysUser();
filter.setDeptId(deptId);
filter.setUserStatus(SysUserStatus.STATUS_NORMAL);
List<SysUser> userList = sysUserService.getSysUserList(filter, null);
this.extractAndAppendUsernameList(usernameSet, userList);
}
return usernameSet;
}
@Override
public Set<String> getUsernameListByPostIds(Set<String> postIdSet) {
Set<String> usernameSet = new HashSet<>();
Set<Long> postIdSet2 = postIdSet.stream().map(Long::valueOf).collect(Collectors.toSet());
SysUser filter = new SysUser();
filter.setUserStatus(SysUserStatus.STATUS_NORMAL);
for (Long postId : postIdSet2) {
List<SysUser> userList = sysUserService.getSysUserListByPostId(postId, filter, null);
this.extractAndAppendUsernameList(usernameSet, userList);
}
return usernameSet;
}
@Override
public Set<String> getUsernameListByDeptPostIds(Set<String> deptPostIdSet) {
Set<String> usernameSet = new HashSet<>();
Set<Long> deptPostIdSet2 = deptPostIdSet.stream().map(Long::valueOf).collect(Collectors.toSet());
SysUser filter = new SysUser();
filter.setUserStatus(SysUserStatus.STATUS_NORMAL);
for (Long deptPostId : deptPostIdSet2) {
List<SysUser> userList = sysUserService.getSysUserListByDeptPostId(deptPostId, filter, null);
this.extractAndAppendUsernameList(usernameSet, userList);
}
return usernameSet;
}
@Override
public Boolean supprtDataPerm() {
return true;
}
@Override
public Map<String, String> mapUserShowNameByLoginName(Set<String> loginNameSet) {
if (CollUtil.isEmpty(loginNameSet)) {
return new HashMap<>(1);
}
Map<String, String> resultMap = new HashMap<>(loginNameSet.size());
List<SysUser> userList = sysUserService.getInList("loginName", loginNameSet);
userList.forEach(user -> resultMap.put(user.getLoginName(), user.getShowName()));
return resultMap;
}
private void extractAndAppendUsernameList(Set<String> resultUsernameList, List<SysUser> userList) {
List<String> usernameList = userList.stream().map(SysUser::getLoginName).collect(Collectors.toList());
if (CollUtil.isNotEmpty(usernameList)) {
resultUsernameList.addAll(usernameList);
}
}
}

View File

@@ -1,40 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 行政区划DomainVO对象。
*
* @author Jerry
* @date 2021-06-06
*/
@ApiModel("行政区划实体对象")
@Data
public class AreaCodeVo {
/**
* 行政区划主键Id
*/
@ApiModelProperty(value = "行政区划主键Id", required = true)
private Long areaId;
/**
* 行政区划名称
*/
@ApiModelProperty(value = "行政区划名称")
private String areaName;
/**
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
*/
@ApiModelProperty(value = "行政区划级别")
private Integer areaLevel;
/**
* 父级行政区划Id
*/
@ApiModelProperty(value = "父级行政区划Id")
private Long parentId;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -1,36 +0,0 @@
package com.orangeforms.webadmin.config;
import java.util.HashMap;
import java.util.Map;
/**
* 表示数据源类型的常量对象。
*
* @author Jerry
* @date 2021-06-06
*/
public final class DataSourceType {
public static final int MAIN = 0;
private static final Map<String, Integer> TYPE_MAP = new HashMap<>(2);
static {
TYPE_MAP.put("main", MAIN);
}
/**
* 根据名称获取字典类型。
*
* @param name 数据源在配置中的名称。
* @return 返回可用于多数据源切换的数据源类型。
*/
public static Integer getDataSourceTypeByName(String name) {
return TYPE_MAP.get(name);
}
/**
* 私有构造函数,明确标识该常量类的作用。
*/
private DataSourceType() {
}
}

View File

@@ -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 2021-06-06
*/
@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中已经设置encodingforceEncoding也会重新设置
filterRegistrationBean.addInitParameter("forceEncoding", "true");
filterRegistrationBean.setAsyncSupported(true);
return filterRegistrationBean;
}
}

View File

@@ -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 2021-06-06
*/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AuthenticationInterceptor()).addPathPatterns("/admin/**");
}
}

View File

@@ -1,44 +0,0 @@
package com.orangeforms.webadmin.config;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.orangeforms.common.core.config.DynamicDataSource;
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;
import java.util.HashMap;
import java.util.Map;
/**
* 多数据源配置对象。
*
* @author Jerry
* @date 2021-06-06
*/
@Configuration
@EnableTransactionManagement
@MapperScan(value = {"com.orangeforms.webadmin.*.dao", "com.orangeforms.common.*.dao"})
public class MultiDataSourceConfig {
@Bean(initMethod = "init", destroyMethod = "close")
@ConfigurationProperties(prefix = "spring.datasource.druid.main")
public DataSource mainDataSource() {
return DruidDataSourceBuilder.create().build();
}
@Bean
@Primary
public DynamicDataSource dataSource() {
Map<Object, Object> targetDataSources = new HashMap<>(1);
targetDataSources.put(DataSourceType.MAIN, mainDataSource());
// 如果当前工程支持在线表单这里请务必保证upms数据表所在数据库为缺省数据源。
DynamicDataSource dynamicDataSource = new DynamicDataSource();
dynamicDataSource.setTargetDataSources(targetDataSources);
dynamicDataSource.setDefaultTargetDataSource(mainDataSource());
return dynamicDataSource;
}
}

View File

@@ -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 2021-06-06
*/
@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();
}
}

View File

@@ -1,415 +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.webadmin.upms.model.constant.SysMenuType;
import com.orangeforms.webadmin.upms.model.constant.SysOnlineMenuPermType;
import com.orangeforms.common.online.util.OnlineUtil;
import com.orangeforms.common.online.model.OnlineDatasource;
import com.orangeforms.common.online.service.OnlineDatasourceService;
import com.orangeforms.common.online.api.config.OnlineApiProperties;
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 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 2021-06-06
*/
@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 SysPostService sysPostService;
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysDataPermService sysDataPermService;
@Autowired
private OnlineDatasourceService onlineDatasourceService;
@Autowired
private OnlineApiProperties onlineProperties;
@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
@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 应答结果对象。
*/
@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<SysUserPost> userPostList = sysPostService.getSysUserPostListByUserId(user.getUserId());
if (CollectionUtils.isNotEmpty(userPostList)) {
Set<Long> deptPostIdSet = userPostList.stream().map(SysUserPost::getDeptPostId).collect(Collectors.toSet());
tokenData.setDeptPostIds(StringUtils.join(deptPostIdSet, ","));
Set<Long> postIdSet = userPostList.stream().map(SysUserPost::getPostId).collect(Collectors.toSet());
tokenData.setPostIds(StringUtils.join(postIdSet, ","));
}
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());
}
List<SysMenu> onlineMenuList;
if (isAdmin) {
onlineMenuList = sysMenuService.getAllOnlineMenuList(SysMenuType.TYPE_BUTTON);
} else {
onlineMenuList = sysMenuService.getOnlineMenuListByUserId(user.getUserId(), SysMenuType.TYPE_BUTTON);
}
OnlinePermData onlinePermData = this.getOnlinePermCodeSet(onlineMenuList);
if (CollectionUtils.isNotEmpty(onlinePermData.permCodeSet)) {
permCodeList.addAll(onlinePermData.permCodeSet);
}
jsonData.put("menuList", menuList);
jsonData.put("permCodeList", permCodeList);
if (user.getUserType() != SysUserType.TYPE_ADMIN) {
// 缓存用户的权限资源
sysPermService.putUserSysPermCache(sessionId, user.getUserId());
sysPermService.putOnlinePermToCache(sessionId, onlinePermData.permUrlSet);
sysDataPermService.putDataPermCache(sessionId, user.getUserId(), user.getDeptId());
}
return jsonData;
}
private OnlinePermData getOnlinePermCodeSet(List<SysMenu> onlineMenuList) {
OnlinePermData permData = new OnlinePermData();
if (CollectionUtils.isEmpty(onlineMenuList)) {
return permData;
}
Set<Long> viewFormIdSet = new HashSet<>();
Set<Long> editFormIdSet = new HashSet<>();
for (SysMenu menu : onlineMenuList) {
if (menu.getOnlineMenuPermType() == SysOnlineMenuPermType.TYPE_VIEW) {
viewFormIdSet.add(menu.getOnlineFormId());
} else if (menu.getOnlineMenuPermType() == SysOnlineMenuPermType.TYPE_EDIT) {
editFormIdSet.add(menu.getOnlineFormId());
}
}
if (CollectionUtils.isNotEmpty(viewFormIdSet)) {
List<OnlineDatasource> viewDatasourceList =
onlineDatasourceService.getOnlineDatasourceListByFormIds(viewFormIdSet);
for (OnlineDatasource datasource : viewDatasourceList) {
permData.permCodeSet.add(OnlineUtil.makeViewPermCode(datasource.getVariableName()));
for (String permUrl : onlineProperties.getViewUrlList()) {
permData.permUrlSet.add(permUrl + datasource.getVariableName());
}
}
}
if (CollectionUtils.isNotEmpty(editFormIdSet)) {
List<OnlineDatasource> editableDatasourceList =
onlineDatasourceService.getOnlineDatasourceListByFormIds(editFormIdSet);
for (OnlineDatasource datasource : editableDatasourceList) {
permData.permCodeSet.add(OnlineUtil.makeEditPermCode(datasource.getVariableName()));
for (String permUrl : onlineProperties.getEditUrlList()) {
permData.permUrlSet.add(permUrl + datasource.getVariableName());
}
}
}
// 这个非常非常重要不能删除。因为在线票单的url前缀是可以配置的那么表单字典接口的url也是动态。
// 所以就不能把这个字典列表接口放到数据库的白名单表中。
permData.permUrlSet.add(onlineProperties.getUrlPrefix() + "/onlineOperation/listDict");
permData.permUrlSet.add(onlineProperties.getUrlPrefix() + "/onlineForm/render");
permData.permUrlSet.add(onlineProperties.getUrlPrefix() + "/onlineForm/view");
return permData;
}
static class OnlinePermData {
public final Set<String> permCodeSet = new HashSet<>();
public final Set<String> permUrlSet = new HashSet<>();
}
}

View File

@@ -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 2021-06-06
*/
@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);
}
}

View File

@@ -1,293 +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 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 2021-06-06
*/
@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"})
@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"})
@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 应答数据结果。
*/
@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 应答结果对象。
*/
@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 应答数据结果。
*/
@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();
}
}

View File

@@ -1,380 +0,0 @@
package com.orangeforms.webadmin.upms.controller;
import cn.jimmyshi.beanquery.BeanQuery;
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.*;
import java.util.stream.Collectors;
/**
* 部门管理操作控制器类。
*
* @author Jerry
* @date 2021-06-06
*/
@Api(tags = "部门管理管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/sysDept")
public class SysDeptController {
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysPostService sysPostService;
/**
* 新增部门管理数据。
*
* @param sysDeptDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"sysDeptDto.deptId"})
@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 应答结果对象。
*/
@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 应答结果对象。
*/
@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);
}
/**
* 列出不与指定部门管理存在多对多关系的 [岗位管理] 列表数据。通常用于查看添加新 [岗位管理] 对象的候选列表。
*
* @param deptId 主表关联字段。
* @param sysPostDtoFilter [岗位管理] 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,返回符合条件的数据列表。
*/
@PostMapping("/listNotInSysDeptPost")
public ResponseResult<MyPageData<SysPostVo>> listNotInSysDeptPost(
@MyRequestBody Long deptId,
@MyRequestBody SysPostDto sysPostDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.isNotBlankOrNull(deptId) && !sysDeptService.existId(deptId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
SysPost filter = MyModelUtil.copyTo(sysPostDtoFilter, SysPost.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysPost.class);
List<SysPost> sysPostList;
if (MyCommonUtil.isNotBlankOrNull(deptId)) {
sysPostList = sysPostService.getNotInSysPostListByDeptId(deptId, filter, orderBy);
} else {
sysPostList = sysPostService.getSysPostList(filter, orderBy);
sysPostService.buildRelationForDataList(sysPostList, MyRelationParam.dictOnly());
}
return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPost.INSTANCE));
}
/**
* 列出与指定部门管理存在多对多关系的 [岗位管理] 列表数据。
*
* @param deptId 主表关联字段。
* @param sysPostDtoFilter [岗位管理] 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,返回符合条件的数据列表。
*/
@PostMapping("/listSysDeptPost")
public ResponseResult<MyPageData<SysPostVo>> listSysDeptPost(
@MyRequestBody(required = true) Long deptId,
@MyRequestBody SysPostDto sysPostDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (!sysDeptService.existId(deptId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
SysPost filter = MyModelUtil.copyTo(sysPostDtoFilter, SysPost.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysPost.class);
List<SysPost> sysPostList = sysPostService.getSysPostListByDeptId(deptId, filter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPost.INSTANCE));
}
/**
* 批量添加部门管理和 [岗位管理] 对象的多对多关联关系数据。
*
* @param deptId 主表主键Id。
* @param sysDeptPostDtoList 关联对象列表。
* @return 应答结果对象。
*/
@PostMapping("/addSysDeptPost")
public ResponseResult<Void> addSysDeptPost(
@MyRequestBody Long deptId,
@MyRequestBody(elementType = SysDeptPostDto.class) List<SysDeptPostDto> sysDeptPostDtoList) {
if (MyCommonUtil.existBlankArgument(deptId, sysDeptPostDtoList)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
String errorMessage = MyCommonUtil.getModelValidationError(sysDeptPostDtoList);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
Set<Long> postIdSet = sysDeptPostDtoList.stream().map(SysDeptPostDto::getPostId).collect(Collectors.toSet());
if (!sysDeptService.existId(deptId) || !sysPostService.existUniqueKeyList("postId", postIdSet)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
List<SysDeptPost> sysDeptPostList = MyModelUtil.copyCollectionTo(sysDeptPostDtoList, SysDeptPost.class);
sysDeptService.addSysDeptPostList(sysDeptPostList, deptId);
return ResponseResult.success();
}
/**
* 更新指定部门管理和指定 [岗位管理] 的多对多关联数据。
*
* @param sysDeptPostDto 对多对中间表对象。
* @return 应答结果对象。
*/
@PostMapping("/updateSysDeptPost")
public ResponseResult<Void> updateSysDeptPost(@MyRequestBody SysDeptPostDto sysDeptPostDto) {
String errorMessage = MyCommonUtil.getModelValidationError(sysDeptPostDto);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysDeptPost sysDeptPost = MyModelUtil.copyTo(sysDeptPostDto, SysDeptPost.class);
if (!sysDeptService.updateSysDeptPost(sysDeptPost)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 显示部门管理和指定 [岗位管理] 的多对多关联详情数据。
*
* @param deptId 主表主键Id。
* @param postId 从表主键Id。
* @return 应答结果对象,包括中间表详情。
*/
@GetMapping("/viewSysDeptPost")
public ResponseResult<SysDeptPostVo> viewSysDeptPost(@RequestParam Long deptId, @RequestParam Long postId) {
if (MyCommonUtil.existBlankArgument(deptId, postId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
SysDeptPost sysDeptPost = sysDeptService.getSysDeptPost(deptId, postId);
if (sysDeptPost == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
SysDeptPostVo sysDeptPostVo = MyModelUtil.copyTo(sysDeptPost, SysDeptPostVo.class);
return ResponseResult.success(sysDeptPostVo);
}
/**
* 移除指定部门管理和指定 [岗位管理] 的多对多关联关系。
*
* @param deptId 主表主键Id。
* @param postId 从表主键Id。
* @return 应答结果对象。
*/
@PostMapping("/deleteSysDeptPost")
public ResponseResult<Void> deleteSysDeptPost(@MyRequestBody Long deptId, @MyRequestBody Long postId) {
if (MyCommonUtil.existBlankArgument(deptId, postId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!sysDeptService.removeSysDeptPost(deptId, postId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 获取部门岗位多对多关联数据,及其关联的部门和岗位数据。
*
* @param deptId 部门Id如果为空返回全部数据列表。
* @return 部门岗位多对多关联数据,及其关联的部门和岗位数据
*/
@GetMapping("/listSysDeptPostWithRelation")
public ResponseResult<List<Map<String, Object>>> listSysDeptPostWithRelation(
@RequestParam(required = false) Long deptId) {
return ResponseResult.success(sysDeptService.getSysDeptPostListWithRelationByDeptId(deptId));
}
/**
* 以字典形式返回全部部门管理数据集合。字典的键值为[deptId, deptName]。
* 白名单接口,登录用户均可访问。
*
* @param filter 过滤对象。
* @return 应答结果对象,包含的数据为 List<Map<String, String>>map中包含两条记录key的值分别是id和namevalue对应具体数据。
*/
@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();
}
}

View File

@@ -1,219 +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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.groups.Default;
import java.util.*;
/**
* 菜单管理接口控制器类。
*
* @author Jerry
* @date 2021-06-06
*/
@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"})
@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 应答结果对象。
*/
@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 应答结果对象。
*/
@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));
}
}

View File

@@ -1,190 +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 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 2021-06-06
*/
@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"})
@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 应答结果对象。
*/
@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 应答结果对象。
*/
@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));
}
}

View File

@@ -1,191 +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 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 2021-06-06
*/
@Api(tags = "权限资源管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/sysPerm")
public class SysPermController {
@Autowired
private SysPermService sysPermService;
/**
* 新增权限资源操作。
*
* @param sysPermDto 新增权限资源对象。
* @return 应答结果对象包含新增权限资源的主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"sysPermDto.permId"})
@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。
*/
@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 应答结果对象。
*/
@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));
}
}

View File

@@ -1,163 +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 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 2021-06-06
*/
@Api(tags = "权限资源模块管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/sysPermModule")
public class SysPermModuleController {
@Autowired
private SysPermModuleService sysPermModuleService;
/**
* 新增权限资源模块操作。
*
* @param sysPermModuleDto 新增权限资源模块对象。
* @return 应答结果对象包含新增权限资源模块的主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"sysPermModuleDto.moduleId"})
@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。
*/
@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 应答结果对象。
*/
@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);
}
}

View File

@@ -1,173 +0,0 @@
package com.orangeforms.webadmin.upms.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import cn.jimmyshi.beanquery.BeanQuery;
import com.github.pagehelper.page.PageMethod;
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.core.validator.UpdateGroup;
import com.orangeforms.webadmin.upms.dto.SysPostDto;
import com.orangeforms.webadmin.upms.model.SysPost;
import com.orangeforms.webadmin.upms.service.SysPostService;
import com.orangeforms.webadmin.upms.vo.SysPostVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import javax.validation.groups.Default;
/**
* 岗位管理操作控制器类。
*
* @author Jerry
* @date 2021-06-06
*/
@Api(tags = "岗位管理操作管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/sysPost")
public class SysPostController {
@Autowired
private SysPostService sysPostService;
/**
* 新增岗位管理数据。
*
* @param sysPostDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"sysPostDto.postId"})
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody SysPostDto sysPostDto) {
String errorMessage = MyCommonUtil.getModelValidationError(sysPostDto);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysPost sysPost = MyModelUtil.copyTo(sysPostDto, SysPost.class);
sysPost = sysPostService.saveNew(sysPost);
return ResponseResult.success(sysPost.getPostId());
}
/**
* 更新岗位管理数据。
*
* @param sysPostDto 更新对象。
* @return 应答结果对象。
*/
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody SysPostDto sysPostDto) {
String errorMessage = MyCommonUtil.getModelValidationError(sysPostDto, Default.class, UpdateGroup.class);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysPost sysPost = MyModelUtil.copyTo(sysPostDto, SysPost.class);
SysPost originalSysPost = sysPostService.getById(sysPost.getPostId());
if (originalSysPost == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!sysPostService.update(sysPost, originalSysPost)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除岗位管理数据。
*
* @param postId 删除对象主键Id。
* @return 应答结果对象。
*/
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long postId) {
String errorMessage;
if (MyCommonUtil.existBlankArgument(postId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
// 验证关联Id的数据合法性
SysPost originalSysPost = sysPostService.getById(postId);
if (originalSysPost == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!sysPostService.remove(postId)) {
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
/**
* 列出符合过滤条件的岗位管理列表。
*
* @param sysPostDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<SysPostVo>> list(
@MyRequestBody SysPostDto sysPostDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
SysPost sysPostFilter = MyModelUtil.copyTo(sysPostDtoFilter, SysPost.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysPost.class);
List<SysPost> sysPostList = sysPostService.getSysPostListWithRelation(sysPostFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(sysPostList, SysPost.INSTANCE));
}
/**
* 查看指定岗位管理对象详情。
*
* @param postId 指定对象主键Id。
* @return 应答结果对象,包含对象详情。
*/
@GetMapping("/view")
public ResponseResult<SysPostVo> view(@RequestParam Long postId) {
if (MyCommonUtil.existBlankArgument(postId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
SysPost sysPost = sysPostService.getByIdWithRelation(postId, MyRelationParam.full());
if (sysPost == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
SysPostVo sysPostVo = SysPost.INSTANCE.fromModel(sysPost);
return ResponseResult.success(sysPostVo);
}
/**
* 以字典形式返回全部岗位管理数据集合。字典的键值为[postId, postName]。
* 白名单接口,登录用户均可访问。
*
* @param filter 过滤对象。
* @return 应答结果对象,包含的数据为 List<Map<String, String>>map中包含两条记录key的值分别是id和namevalue对应具体数据。
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict(SysPost filter) {
List<SysPost> resultList = sysPostService.getListByFilter(filter);
return ResponseResult.success(BeanQuery.select("postId as id", "postName as name").executeFrom(resultList));
}
/**
* 根据字典Id集合获取查询后的字典数据。
*
* @param postIds 字典Id集合。
* @return 应答结果对象,包含字典形式的数据集合。
*/
@PostMapping("/listDictByIds")
public ResponseResult<List<Map<String, Object>>> listDictByIds(
@MyRequestBody(elementType = Long.class) List<Long> postIds) {
List<SysPost> resultList = sysPostService.getInList(new HashSet<>(postIds));
return ResponseResult.success(BeanQuery.select("postId as id", "postName as name").executeFrom(resultList));
}
}

View File

@@ -1,351 +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 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 2021-06-06
*/
@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"})
@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"})
@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 应答结果对象。
*/
@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 应答结果对象。
*/
@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 应答数据结果。
*/
@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和namevalue对应具体数据。
*/
@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));
}
}

View File

@@ -1,358 +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.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 2021-06-06
*/
@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 deptPostIdListString 逗号分隔的部门岗位Id列表。
* @param dataPermIdListString 逗号分隔的数据权限Id列表。
* @param roleIdListString 逗号分隔的角色Id列表。
* @return 应答结果对象包含新增用户的主键Id。
*/
@ApiOperationSupport(ignoreParameters = {
"sysUserDto.userId",
"sysUserDto.createTimeStart",
"sysUserDto.createTimeEnd"})
@PostMapping("/add")
public ResponseResult<Long> add(
@MyRequestBody SysUserDto sysUserDto,
@MyRequestBody String deptPostIdListString,
@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, deptPostIdListString, dataPermIdListString);
if (!result.isSuccess()) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
}
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>() {});
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, deptPostIdSet, dataPermIdSet);
return ResponseResult.success(sysUser.getUserId());
}
/**
* 更新用户操作。
*
* @param sysUserDto 更新用户对象。
* @param deptPostIdListString 逗号分隔的部门岗位Id列表。
* @param dataPermIdListString 逗号分隔的数据权限Id列表。
* @param roleIdListString 逗号分隔的角色Id列表。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"sysUserDto.createTimeStart",
"sysUserDto.createTimeEnd"})
@PostMapping("/update")
public ResponseResult<Void> update(
@MyRequestBody SysUserDto sysUserDto,
@MyRequestBody String deptPostIdListString,
@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, deptPostIdListString, dataPermIdListString);
if (!result.isSuccess()) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
}
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>() {});
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, deptPostIdSet, 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 应答结果对象。
*/
@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 应答对象。
*/
@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 上传文件对象。
*/
@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();
}
}

View File

@@ -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 2021-06-06
*/
public interface SysDataPermDeptMapper extends BaseDaoMapper<SysDataPermDept> {
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -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 2021-06-06
*/
public interface SysDataPermUserMapper extends BaseDaoMapper<SysDataPermUser> {
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.upms.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.upms.model.SysDeptPost;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 部门岗位数据操作访问接口。
*
* @author Jerry
* @date 2021-06-06
*/
public interface SysDeptPostMapper extends BaseDaoMapper<SysDeptPost> {
/**
* 获取指定部门Id的部门岗位多对多关联数据列表以及关联的部门和岗位数据。
*
* @param deptId 部门Id。如果参数为空则返回全部数据。
* @return 部门岗位多对多数据列表。
*/
List<Map<String, Object>> getSysDeptPostListWithRelationByDeptId(@Param("deptId") Long deptId);
/**
* 获取指定部门Id的领导部门岗位列表。
*
* @param deptId 部门Id。
* @return 指定部门Id的领导部门岗位列表
*/
List<SysDeptPost> getLeaderDeptPostList(@Param("deptId") Long deptId);
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -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 2021-06-06
*/
public interface SysMenuPermCodeMapper extends BaseDaoMapper<SysMenuPermCode> {
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -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 2021-06-06
*/
public interface SysPermCodePermMapper extends BaseDaoMapper<SysPermCodePerm> {
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -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 2021-06-06
*/
public interface SysPermModuleMapper extends BaseDaoMapper<SysPermModule> {
/**
* 获取整个权限模块和权限关联后的全部数据。
*
* @return 关联的权限模块和权限资源列表。
*/
List<SysPermModule> getPermModuleAndPermList();
}

View File

@@ -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 2021-06-06
*/
public interface SysPermWhitelistMapper extends BaseDaoMapper<SysPermWhitelist> {
}

View File

@@ -1,52 +0,0 @@
package com.orangeforms.webadmin.upms.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.upms.model.SysPost;
import org.apache.ibatis.annotations.Param;
import java.util.*;
/**
* 岗位管理数据操作访问接口。
*
* @author Jerry
* @date 2021-06-06
*/
public interface SysPostMapper extends BaseDaoMapper<SysPost> {
/**
* 获取过滤后的对象列表。
*
* @param sysPostFilter 主表过滤对象。
* @param orderBy 排序字符串order by从句的参数。
* @return 对象列表。
*/
List<SysPost> getSysPostList(
@Param("sysPostFilter") SysPost sysPostFilter, @Param("orderBy") String orderBy);
/**
* 获取指定部门的岗位列表。
*
* @param deptId 部门Id。
* @param sysPostFilter 从表过滤对象。
* @param orderBy 排序字符串order by从句的参数。
* @return 岗位数据列表。
*/
List<SysPost> getSysPostListByDeptId(
@Param("deptId") Long deptId,
@Param("sysPostFilter") SysPost sysPostFilter,
@Param("orderBy") String orderBy);
/**
* 根据关联主表Id获取关联从表中没有和主表建立关联关系的数据列表。
*
* @param deptId 关联主表Id。
* @param sysPostFilter 过滤对象。
* @param orderBy 排序字符串order by从句的参数。
* @return 与主表没有建立关联的从表数据列表。
*/
List<SysPost> getNotInSysPostListByDeptId(
@Param("deptId") Long deptId,
@Param("sysPostFilter") SysPost sysPostFilter,
@Param("orderBy") String orderBy);
}

View File

@@ -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 2021-06-06
*/
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);
}

View File

@@ -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 2021-06-06
*/
public interface SysRoleMenuMapper extends BaseDaoMapper<SysRoleMenu> {
}

View File

@@ -1,154 +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 2021-06-06
*/
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);
/**
* 根据部门岗位Id获取关联的用户Id列表。
*
* @param deptPostId 关联的部门岗位Id。
* @param sysUserFilter 用户过滤条件对象。
* @param orderBy order by从句的参数。
* @return 和DeptPostId关联的用户列表。
*/
List<SysUser> getSysUserListByDeptPostId(
@Param("deptPostId") Long deptPostId,
@Param("sysUserFilter") SysUser sysUserFilter,
@Param("orderBy") String orderBy);
/**
* 根据部门岗位Id获取和当前部门岗位Id没有建立多对多关联关系的用户Id列表。
*
* @param deptPostId 关联的部门岗位Id。
* @param sysUserFilter 用户过滤条件对象。
* @param orderBy order by从句的参数。
* @return 和deptPostId没有建立关联关系的用户列表。
*/
List<SysUser> getNotInSysUserListByDeptPostId(
@Param("deptPostId") Long deptPostId,
@Param("sysUserFilter") SysUser sysUserFilter,
@Param("orderBy") String orderBy);
/**
* 根据岗位Id获取关联的用户Id列表。
*
* @param postId 关联的岗位Id。
* @param sysUserFilter 用户过滤条件对象。
* @param orderBy order by从句的参数。
* @return 和postId关联的用户列表。
*/
List<SysUser> getSysUserListByPostId(
@Param("postId") Long postId,
@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);
}

View File

@@ -1,13 +0,0 @@
package com.orangeforms.webadmin.upms.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.upms.model.SysUserPost;
/**
* 用户岗位数据操作访问接口。
*
* @author Jerry
* @date 2021-06-06
*/
public interface SysUserPostMapper extends BaseDaoMapper<SysUserPost> {
}

View File

@@ -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 2021-06-06
*/
public interface SysUserRoleMapper extends BaseDaoMapper<SysUserRole> {
}

View File

@@ -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>

View File

@@ -1,62 +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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</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 IFNULL(zz_sys_data_perm.data_perm_name, '') LIKE #{safeSearchString}
</if>
</if>
AND zz_sys_data_perm.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
</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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -1,46 +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.SysDeptPostMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysDeptPost">
<id column="dept_post_id" jdbcType="BIGINT" property="deptPostId"/>
<result column="dept_id" jdbcType="BIGINT" property="deptId"/>
<result column="post_id" jdbcType="BIGINT" property="postId"/>
<result column="post_show_name" jdbcType="VARCHAR" property="postShowName"/>
</resultMap>
<select id="getSysDeptPostListWithRelationByDeptId" resultType="map">
SELECT
a.dept_post_id deptPostId,
a.dept_id deptId,
a.post_id postId,
a.post_show_name postShowName,
b.dept_name deptName,
c.level,
c.leader_post leaderPost
FROM
zz_sys_dept_post a,
zz_sys_dept b,
zz_sys_post c
<where>
a.dept_id = b.dept_id
AND a.post_id = c.post_id
<if test="deptId != null">
AND a.dept_id = #{deptId}
</if>
</where>
</select>
<select id="getLeaderDeptPostList" resultMap="BaseResultMap">
SELECT
a.*
FROM
zz_sys_dept_post a,
zz_sys_post b
WHERE
a.post_id = b.post_id
AND b.leader_post = 1
AND a.dept_id = #{deptId}
ORDER BY
b.level
</select>
</mapper>

View File

@@ -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>

View File

@@ -1,109 +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="online_flow_entry_id" jdbcType="BIGINT" property="onlineFlowEntryId"/>
<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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</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 &lt;= ${@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>

View File

@@ -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>

View File

@@ -1,91 +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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</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>

View File

@@ -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>

View File

@@ -1,132 +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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</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>

View File

@@ -1,44 +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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</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 AND p.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
<where>
AND pm.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
</where>
ORDER BY
pm.show_order, p.show_order
</select>
</mapper>

View File

@@ -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>

View File

@@ -1,82 +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.SysPostMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysPost">
<id column="post_id" jdbcType="BIGINT" property="postId"/>
<result column="post_name" jdbcType="VARCHAR" property="postName"/>
<result column="level" jdbcType="INTEGER" property="level"/>
<result column="leader_post" jdbcType="BOOLEAN" property="leaderPost"/>
<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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</resultMap>
<resultMap id="BaseResultMapWithSysDeptPost" type="com.orangeforms.webadmin.upms.model.SysPost" extends="BaseResultMap">
<association property="sysDeptPost" column="post_id" foreignColumn="post_id"
notNullColumn="post_id" resultMap="com.orangeforms.webadmin.upms.dao.SysDeptPostMapper.BaseResultMap" />
</resultMap>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.webadmin.upms.dao.SysPostMapper.inputFilterRef"/>
AND zz_sys_post.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
</sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
<sql id="inputFilterRef">
<if test="sysPostFilter != null">
<if test="sysPostFilter.postName != null and sysPostFilter.postName != ''">
<bind name = "safeSysPostPostName" value = "'%' + sysPostFilter.postName + '%'" />
AND zz_sys_post.post_name LIKE #{safeSysPostPostName}
</if>
<if test="sysPostFilter.leaderPost != null">
AND zz_sys_post.leader_post = #{sysPostFilter.leaderPost}
</if>
</if>
</sql>
<select id="getSysPostList" resultMap="BaseResultMap" parameterType="com.orangeforms.webadmin.upms.model.SysPost">
SELECT * FROM zz_sys_post
<where>
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<select id="getSysPostListByDeptId" resultMap="BaseResultMapWithSysDeptPost">
SELECT
zz_sys_post.*,
zz_sys_dept_post.*
FROM
zz_sys_post,
zz_sys_dept_post
<where>
AND zz_sys_dept_post.dept_id = #{deptId}
AND zz_sys_dept_post.post_id = zz_sys_post.post_id
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<select id="getNotInSysPostListByDeptId" resultMap="BaseResultMap">
SELECT
zz_sys_post.*
FROM
zz_sys_post
<where>
AND NOT EXISTS (SELECT * FROM zz_sys_dept_post
WHERE zz_sys_dept_post.dept_id = #{deptId} AND zz_sys_dept_post.post_id = zz_sys_post.post_id)
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
</mapper>

View File

@@ -1,91 +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"/>
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
</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>
AND deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
</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>

View File

@@ -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>

View File

@@ -1,290 +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 &gt;= #{sysUserFilter.createTimeStart}
</if>
<if test="sysUserFilter.createTimeEnd != null and sysUserFilter.createTimeEnd != ''">
AND zz_sys_user.create_time &lt;= #{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="getSysUserListByDeptPostId" resultMap="BaseResultMap">
SELECT
zz_sys_user.*
FROM
zz_sys_user_post,
zz_sys_user
<where>
AND zz_sys_user_post.dept_post_id = #{deptPostId}
AND zz_sys_user_post.user_id = zz_sys_user.user_id
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<select id="getNotInSysUserListByDeptPostId" resultMap="BaseResultMap">
SELECT * FROM zz_sys_user
<where>
NOT EXISTS (SELECT * FROM zz_sys_user_post
WHERE zz_sys_user_post.dept_post_id = #{deptPostId} AND zz_sys_user_post.user_id = zz_sys_user.user_id)
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<select id="getSysUserListByPostId" resultMap="BaseResultMap">
SELECT
zz_sys_user.*
FROM
zz_sys_user_post,
zz_sys_user
<where>
AND zz_sys_user_post.post_id = #{postId}
AND zz_sys_user_post.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>

View File

@@ -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.SysUserPostMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.upms.model.SysUserPost">
<id column="user_id" jdbcType="BIGINT" property="userId"/>
<id column="dept_post_id" jdbcType="BIGINT" property="deptPostId"/>
<id column="post_id" jdbcType="BIGINT" property="postId"/>
</resultMap>
</mapper>

View File

@@ -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>

View File

@@ -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 2021-06-06
*/
@ApiModel("数据权限与部门关联Dto")
@Data
public class SysDataPermDeptDto {
/**
* 数据权限Id。
*/
@ApiModelProperty(value = "数据权限Id", required = true)
private Long dataPermId;
/**
* 关联部门Id。
*/
@ApiModelProperty(value = "关联部门Id", required = true)
private Long deptId;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -1,48 +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 2021-06-06
*/
@ApiModel("部门岗位Dto")
@Data
public class SysDeptPostDto {
/**
* 部门岗位Id。
*/
@ApiModelProperty(value = "部门岗位Id", required = true)
@NotNull(message = "数据验证失败部门岗位Id不能为空", groups = {UpdateGroup.class})
private Long deptPostId;
/**
* 部门Id。
*/
@ApiModelProperty(value = "部门Id", required = true)
@NotNull(message = "数据验证失败部门Id不能为空", groups = {UpdateGroup.class})
private Long deptId;
/**
* 岗位Id。
*/
@ApiModelProperty(value = "岗位Id", required = true)
@NotNull(message = "数据验证失败岗位Id不能为空", groups = {UpdateGroup.class})
private Long postId;
/**
* 部门岗位显示名称。
*/
@ApiModelProperty(value = "部门岗位显示名称", required = true)
@NotBlank(message = "数据验证失败,部门岗位显示名称不能为空!")
private String postShowName;
}

View File

@@ -1,81 +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 2021-06-06
*/
@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;
/**
* 仅用于在线表单的流程Id。
*/
@ApiModelProperty(value = "仅用于在线表单的流程Id")
private Long onlineFlowEntryId;
/**
* 菜单显示顺序 (值越小,排序越靠前)。
*/
@ApiModelProperty(value = "菜单显示顺序", required = true)
@NotNull(message = "菜单显示顺序不能为空!")
private Integer showOrder;
/**
* 菜单图标。
*/
@ApiModelProperty(value = "菜单显示顺序")
private String icon;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -1,48 +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 2021-06-06
*/
@ApiModel("岗位Dto")
@Data
public class SysPostDto {
/**
* 岗位Id。
*/
@ApiModelProperty(value = "岗位Id", required = true)
@NotNull(message = "数据验证失败岗位Id不能为空", groups = {UpdateGroup.class})
private Long postId;
/**
* 岗位名称。
*/
@ApiModelProperty(value = "岗位名称", required = true)
@NotBlank(message = "数据验证失败,岗位名称不能为空!")
private String postName;
/**
* 岗位层级,数值越小级别越高。
*/
@ApiModelProperty(value = "岗位层级", required = true)
@NotNull(message = "数据验证失败,岗位层级不能为空!")
private Integer level;
/**
* 是否领导岗位。
*/
@ApiModelProperty(value = "是否领导岗位", required = true)
@NotNull(message = "数据验证失败,领导岗位不能为空!", groups = {UpdateGroup.class})
private Boolean leaderPost;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -1,113 +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 2021-06-06
*/
@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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
@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);
}

View File

@@ -1,29 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.ToString;
/**
* 数据权限与部门关联实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -1,27 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 数据权限与用户关联实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -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 2021-06-06
*/
@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);
}

View File

@@ -1,39 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 部门岗位多对多关联实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@Data
@TableName(value = "zz_sys_dept_post")
public class SysDeptPost {
/**
* 部门岗位Id。
*/
@TableId(value = "dept_post_id")
private Long deptPostId;
/**
* 部门Id。
*/
@TableField(value = "dept_id")
private Long deptId;
/**
* 岗位Id。
*/
@TableField(value = "post_id")
private Long postId;
/**
* 部门岗位显示名称。
*/
@TableField(value = "post_show_name")
private String postShowName;
}

View File

@@ -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 2021-06-06
*/
@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;
}

View File

@@ -1,143 +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 2021-06-06
*/
@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;
/**
* 仅用于在线表单的流程Id。
*/
@TableField(value = "online_flow_entry_id")
private Long onlineFlowEntryId;
/**
* 菜单显示顺序 (值越小,排序越靠前)。
*/
@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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
@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);
}

View File

@@ -1,27 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 菜单与权限字关联实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -1,87 +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 2021-06-06
*/
@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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
@RelationDict(
masterIdField = "moduleId",
slaveServiceName = "SysPermModuleService",
slaveModelClass = SysPermModule.class,
slaveIdField = "moduleId",
slaveNameField = "moduleName")
@TableField(exist = false)
private Map<String, Object> moduleIdDictMap;
}

View File

@@ -1,120 +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 2021-06-06
*/
@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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
@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);
}

View File

@@ -1,27 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 权限字与权限资源关联实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -1,81 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.*;
/**
* 权限模块实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
@TableField(exist = false)
private List<SysPerm> sysPermList;
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 白名单实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -1,104 +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.SysPostVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
/**
* 岗位实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@Data
@TableName(value = "zz_sys_post")
public class SysPost {
/**
* 岗位Id。
*/
@TableId(value = "post_id")
private Long postId;
/**
* 岗位名称。
*/
@TableField(value = "post_name")
private String postName;
/**
* 岗位层级,数值越小级别越高。
*/
private Integer level;
/**
* 是否领导岗位。
*/
@TableField(value = "leader_post")
private Boolean leaderPost;
/**
* 创建者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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
/**
* postId 的多对多关联表数据对象。
*/
@TableField(exist = false)
private SysDeptPost sysDeptPost;
@Mapper
public interface SysPostModelMapper extends BaseModelMapper<SysPostVo, SysPost> {
/**
* 转换Vo对象到实体对象。
*
* @param sysPostVo 域对象。
* @return 实体对象。
*/
@Mapping(target = "sysDeptPost", expression = "java(mapToBean(sysPostVo.getSysDeptPost(), com.orangeforms.webadmin.upms.model.SysDeptPost.class))")
@Override
SysPost toModel(SysPostVo sysPostVo);
/**
* 转换实体对象到VO对象。
*
* @param sysPost 实体对象。
* @return 域对象。
*/
@Mapping(target = "sysDeptPost", expression = "java(beanToMap(sysPost.getSysDeptPost(), false))")
@Override
SysPostVo fromModel(SysPost sysPost);
}
public static final SysPostModelMapper INSTANCE = Mappers.getMapper(SysPostModelMapper.class);
}

View File

@@ -1,96 +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 2021-06-06
*/
@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;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
@TableField(value = "deleted_flag")
private Integer deletedFlag;
@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);
}

View File

@@ -1,27 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 角色菜单实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -1,196 +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 2021-06-06
*/
@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 = "sysUserPostMapper",
relationMasterIdField = "userId",
relationModelClass = SysUserPost.class)
@TableField(exist = false)
private List<SysUserPost> sysUserPostList;
/**
* 多对多用户角色数据集合。
*/
@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 = "sysUserPostList", expression = "java(mapToBean(sysUserVo.getSysUserPostList(), com.orangeforms.webadmin.upms.model.SysUserPost.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 = "sysUserPostList", expression = "java(beanToMap(sysUser.getSysUserPostList(), false))")
@Mapping(target = "sysDataPermUserList", expression = "java(beanToMap(sysUser.getSysDataPermUserList(), false))")
@Override
SysUserVo fromModel(SysUser sysUser);
}
public static final SysUserModelMapper INSTANCE = Mappers.getMapper(SysUserModelMapper.class);
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 用户岗位多对多关系实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@Data
@TableName(value = "zz_sys_user_post")
public class SysUserPost {
/**
* 用户Id。
*/
@TableField(value = "user_id")
private Long userId;
/**
* 部门岗位Id。
*/
@TableField(value = "dept_post_id")
private Long deptPostId;
/**
* 岗位Id。
*/
@TableField(value = "post_id")
private Long postId;
}

View File

@@ -1,27 +0,0 @@
package com.orangeforms.webadmin.upms.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 用户角色实体对象。
*
* @author Jerry
* @date 2021-06-06
*/
@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;
}

View File

@@ -1,54 +0,0 @@
package com.orangeforms.webadmin.upms.model.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 菜单类型常量对象。
*
* @author Jerry
* @date 2021-06-06
*/
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() {
}
}

View File

@@ -1,44 +0,0 @@
package com.orangeforms.webadmin.upms.model.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 菜单关联在线表单的控制权限类型。
*
* @author Jerry
* @date 2021-06-06
*/
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() {
}
}

Some files were not shown because too many files have changed in this diff Show More